Element.update不是函数[Rails 3 + JQuery] [英] Element.update is not a function [Rails 3 + JQuery]
问题描述
我正在尝试将JQuery集成到Rails 3中.我已经从下载了rails.js文件. http://github.com/rails/jquery-ujs 并将其包含在我的应用程序中.我还包括了JQuery.
I'm attempting to integrate JQuery into Rails 3. I've downloaded the rails.js file from http://github.com/rails/jquery-ujs and have included it in my app. I've also include JQuery.
但是当我尝试做一个简单的page.replace像这样:
But when I attempt to do a simple page.replace like so:
render :update do |page|
page.replace_html "my_div", :partial => "my_partial", :locals => {:mylocal => mylocal}
end
我从正在执行的javascript中抛出以下错误:
I get the following error thrown from the javascript executing:
RJS error:
TypeError: Element.update is not a function
Element.update("my_div", "mypartialdata");
有什么想法吗?
推荐答案
正如其他人所说的,page.replace
在rails 2中引用Element.update
.
As others have said, page.replace
, in rails 2, references Element.update
.
如果您希望在带有jQuery的Rails 3中使用相同的助手,请查看jrails:
If you want the same helpers available to you in Rails 3 with jQuery, check out jrails:
http://github.com/aaronchi/jrails
如果要在Rails 3中使用assert_select_rjs
测试助手,请在此处获取已修补的版本:
In case you want to use the assert_select_rjs
test helpers in Rails 3, go grab the patched version here:
https://github.com/theworkinggroup/jrails
这篇关于Element.update不是函数[Rails 3 + JQuery]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!