I am developing a small blog with a cool feature to edit articles in the
page through ajax.
So I made my Raisl3 app load jQuery and opened AWDWR3 to learn whether
anything had changed.
So I create an RJS template: edit.js.rjs with:
page.replace_html("article_#{@article.id}",
render('admin/articles/form'))
Obviously when I clicked my edit button that triggers the ajax
replacement of the article by an editable form it failed.
My first surprise was to be greeted by an "Element.update is not a
function" error. I then realized that I cannot use page.replace_html
which is reserved to Prototype.
No big deal I'll create an edit.js.erb file with:
$("#article_<%= @article.id %>").update("<%=
render('admin/articles/form') %>");
The application gets hit, but nothing else happens on the client side.
Anyway, I'm not sure I understand correctly all this ajax stuff in
Rails.
Isn't it an issue to write js code in edit.js.rjs? Since it is dynamic
javascript code, the web browser won't be able to cache it. Am I right?
What's the authoritative way of doing jQuery + Rails3 + Unobstrusive +
Clean + etc?
AWDWR doesn't teach good practices in this point of view.
Thanks
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.