开发者

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

开发者 https://www.devze.com 2023-01-08 22:20 出处:网络
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 P

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

精彩评论

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