Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element.update is not a function [Rails 3 + 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.

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

I get the following error thrown from the javascript executing:

RJS error:
TypeError: Element.update is not a function

Element.update("my_div", "mypartialdata");

Any ideas?

like image 406
Bensign Avatar asked Dec 28 '22 08:12

Bensign


1 Answers

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

like image 172
Jamie Wong Avatar answered Jan 13 '23 12:01

Jamie Wong