dan*_*iel 6 jquery ruby-on-rails prototypejs ruby-on-rails-3
我用JQuery for Rails 3替换了Prototype.我现在尝试执行以下操作:
#photo
=render 'shared/photo'
= link_to_function "Add a Photo" do |page| |
page.insert_html :bottom, 'photo', :partial => 'shared/photo', :object => Photo.new |
end |
Run Code Online (Sandbox Code Playgroud)
所以生成的Javascript是:
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;
Run Code Online (Sandbox Code Playgroud)
在rails docs中,insert_html是一个Prototype帮助器,但我认为用https://github.com/rails/jquery-ujs替换Rails.js 会替换JQuery帮助器的这个帮助器.我得到一个TypeError.ElementInsert不是一个函数.
难道我做错了什么 ?或者我是否会在没有帮助者的情况下自己做这件事?
刚刚有人向我发送了这个问题,也许我可以提供帮助。我在 jquery-ujs/jquery-rails 团队中。
与rails 的prototype-ujs 不同,jquery-ujs 不捆绑rjs 支持。有一个单独的 gem 提供了该功能,称为jrails。
我们已经讨论过合并这两个项目,但决定将它们分开,因为这样更灵活。