I replaced Prototype with JQuery for Rails 3. I am now trying to do the following:
#photo
=render 'shared/photo'
= link_to_function "Add a Photo" do |page| |
page.insert_html :bottom, 'photo', :partial => 'shared/photo', :object => Photo.new |
end |
So the Javascript generated is:
try {
Element.insert("photo", {
bottom: "Data\n\n"
});
} catch (e) {
alert('RJS error:\n\n' + e.toString());
alert('Element.insert(\"photo\", { bottom: \"Data\\n\\n\" });');
throw e
};
return false;
In the rails docs insert_html is a Prototype helper, but I thought that replacing Rails.js with the https://github.com/rails/jquery-ujs would replace this helpers for JQuery helpers. I get a TypeError.ElementInsert is not a function.
Am I doing something wrong ? Or am I going to do this myself without the helpers ?
Someone just sent this question to me, maybe I can help. I'm on the jquery-ujs/jquery-rails team.
Unlike prototype-ujs for rails, jquery-ujs does not come bundled with rjs support. There is a separate gem that provides that functionality called jrails.
We've talked about merging the two projects, but decided to keep them separate, as it's more flexible that way.