How does page.update actually work? I know its a wrapper for Prototype.update but how does it get the partial in there? Say I wanted to update a div with the contents of a partial manually like this. content = render(:partial => ''whatever'') page.call "$(''my_div'').update(#{content})" But his does not work. It keeps giving me weird errors about tags. Any clues? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 22, 12:02 am, Joe Blow <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> How does page.update actually work? I know its a wrapper for > Prototype.update but how does it get the partial in there? > > Say I wanted to update a div with the contents of a partial manually > like this. > > content = render(:partial => ''whatever'') > page.call "$(''my_div'').update(#{content})" > > But his does not work. It keeps giving me weird errors about > tags. Any clues?That''s now how you are supposed to use page.call. The first argument is supposed to be the function to call (ie $(''my_div'').update) and subsequent arguments are arguments to pass through. What your code does is ask the browser to execute $(''my_div'').update(<span>some html here</span>) (assuming that was the html content), ie the string literal is not quoted and is just dumped in there. There is no need to use page.call here though as page.replace_html handles this already (see http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html#M001446 ) Fred --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I am aware of page.update and page.replace_html but I was wondering how it actually works. Basically I have a callback from a scriptaculous effect that will update a div with the results of some partial so I can not use the built in page.xxx calls. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 22, 8:32 pm, Joe Blow <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I am aware of page.update and page.replace_html but I was wondering how > it actually works. > > Basically I have a callback from a scriptaculous effect that will update > a div with the results of some partial so I can not use the built in > page.xxx calls.Your first post rather implied that you could since you were using page.call. Anyway, first off you can use update_page to get an rjs like page object anywhere you happen to be. Secondly prototype''s update stuff is as simple as $(''some_div'').update(''hello world''). If however you are generating the html in rails and then just injecting it into some javascript with #{} then you need to quote the string of html properly (and if you quote the string with " you need to escape any " in the html (and similarly with ''). page.call does all that for you, there''s a helper whose name I forget that does that and to_json would probably do the trick too. Fred> -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---