I'm just getting to grips with rails 3. My latest speedbump is to do with the prototype helpers i use in js.rjs files. In some of my rails 2 apps, i ditched prototype in favour of jquery, and that's what i've done here. To get the helpers, eg page.replace
& page.replace_html
back, i then used the jrails plugin which replicated the functionality but using jquery instead of prototype (or at least that was my understanding of it).
I'm using jquery instead of prototype in my toy rails 3 app and have hit the same problem: the page.replace helper doesn't work:
I have this code in update.js.rjs
:
page.alert "posted"
page.replace "tweets", :partial => "twitter/tweets"
which causes this error from line 2 (the alert runs fine):
RJS error: TypeError: Element.replace is not a function
Do i just need to install the jrails plugin again? Or is there a different solution these days?
grateful for any thoughts - max
EDIT - i get the same problem when i move the code from a js.rjs file into my controller, like so:
respond_to do |format|
format.js do
render :update do |page|
page.alert "posted"
page.replace "tweets", :partial => "twitter/tweets"
end
end
end
EDIT - in the end, for lack of anything else, i just installed the jrails gem and it seems fine now.