Ben*_*ign 4 jquery ruby-on-rails ujs ruby-on-rails-3
我正在尝试将JQuery集成到Rails 3.我已经从http://github.com/rails/jquery-ujs下载了rails.js文件并将其包含在我的应用程序中.我还包括JQuery.
但是当我尝试做一个简单的page.replace时:
render :update do |page|
page.replace_html "my_div", :partial => "my_partial", :locals => {:mylocal => mylocal}
end
Run Code Online (Sandbox Code Playgroud)
我从javascript执行中抛出以下错误:
RJS error:
TypeError: Element.update is not a function
Element.update("my_div", "mypartialdata");
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
Jam*_*ong 12
正如其他人所说,page.replace在rails 2中,参考文献Element.update.
如果你想在使用jQuery的Rails 3中使用相同的帮助程序,请查看jrails:
http://github.com/aaronchi/jrails
如果您想assert_select_rjs在Rails 3中使用测试助手,请在此处获取已修补的版本:
https://github.com/theworkinggroup/jrails