Ruby on Rails:+ AJAX:如何设置字段的值

时间:2010-07-27 20:48:58

标签: ruby-on-rails ajax

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

但有什么地方我可以在文本字段中插入一个值吗?

2 个答案:

答案 0 :(得分:0)

我认为你需要退出 RJS 并进入 Prototype 。例如,如果您的textfield id的值为“foo”,则此类内容可能有效:

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

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

更新value元素的input属性。

答案 1 :(得分:0)

我找到的方法是这样做:

page[:object_column_name].value = whatever

它只是字段的id