开发者

Ruby on Rails: + AJAX: How do I set the value of a field

there is

page.replace_html "id", thing to replace it with

but is there something where I can just insert a value i开发者_JS百科nto a text field?


I think you'll need to drop out of RJS and into Prototype for this one. For example, if your textfield id has a value "foo" then something like this might work:

page << %{
  var input = $('foo');

  input.writeAttribute('value', 'thing to replace it with');
}

updates the value attribute of the input element.


The way I found was to do this:

page[:object_column_name].value = whatever

its just the id of the field

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜