Element.update is not a function [Rails 3 + JQuery]

拥有回忆 提交于 2019-11-29 07:56:38

As others have said, page.replace, in rails 2, references Element.update.

If you want the same helpers available to you in Rails 3 with jQuery, check out jrails:

http://github.com/aaronchi/jrails

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

page.replace will call prototype function Element.update. Have you got prototype included in your page?

agenty

If it really is just the Element.update thing using render(:update) in rails 3 with jQuery, this little js code snippet should do it:

Element = function(){}
Element.update = function(id,html){$('#'+id).html(html);}

parsing this JS code should help. I've put it at the end of the jquery_ujs.js file.

I figured out the problem. Apparently with JQuery, you cannot use the rails helpers like "replace_html" or "insert_html". You merely have to do page << "//Jquery code".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!