I need to call an RJS template from within another template...is there a way to do this? Thank you! Jake --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jake Cutter wrote:> I need to call an RJS template from within another template...is there a > way > to do this? > > Thank you! > > JakeI don''t know of a way. Perhaps if you give us some context we can come up with a different way to solve the problem you are working on. jp -- 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 -~----------~----~----~----~------~----~------~--~---
On 9/21/06, Jeff Pritchard <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I don''t know of a way. Perhaps if you give us some context we can come > up with a different way to solve the problem you are working on.Ok, say I have update_a.rjs and update_b.rjs. update_b.rjs has a lot of complex update logic, etc, that is used by various actions across my code. update_a.rjs in different places as well. update_a.rjs needs to always ensure update_b.rjs is called directly after it. Rather that going around making sure every place that update_a.rjs is rendered also consequently renders update_b.rjs, I was hoping I could simply chain them in some way... Thanks, Jake --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jake Cutter wrote:> On 9/21/06, Jeff Pritchard <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > I don''t know of a way. Perhaps if you give us some context we can come > > up with a different way to solve the problem you are working on. > > > > Ok, say I have update_a.rjs and update_b.rjs. update_b.rjs has a lot of > complex update logic, etc, that is used by various actions across my code. > update_a.rjs in different places as well. > > update_a.rjs needs to always ensure update_b.rjs is called directly after > it. Rather that going around making sure every place that update_a.rjs is > rendered also consequently renders update_b.rjs, I was hoping I could simply > chain them in some way... > > Thanks, > Jake > > ------=_Part_8415_15296355.1158862352948 > Content-Type: text/html; charset=ISO-8859-1 > X-Google-AttachSize: 996 > > On 9/21/06, <b class="gmail_sendername">Jeff Pritchard</b> <<a href="mailto:rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org">rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> > I don''t know of a way. Perhaps if you give us some context we can come<br>up with a different way to solve the problem you are working on.</blockquote><div><br><br>Ok, say I have update_a.rjs and update_b.rjs. update_b.rjs has a lot of complex update logic, etc, that is used by various actions across my code. update_a.rjs in different places as well. > <br><br>update_a.rjs needs to always ensure update_b.rjs is called directly after it. Rather that going around making sure every place that update_a.rjs is rendered also consequently renders update_b.rjs, I was hoping I could simply chain them in some way... > <br><br>Thanks,<br>Jake<br></div><br></div> > > ------=_Part_8415_15296355.1158862352948--You could try something like this.. def rjs_a h = headers[''Content-Type''] render :update do |page| page << self.send("rjs_b") @performed_render = false headers[''Content-Type''] = h end end Untested, but some variation on this should work. The @performed render call will prevent you from getting double render errors The header magic is sometimes required to prevent your browser from just rendering the response as text. You may not need it here. _Kevin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I ran into this problem about a month ago. I couldn''t find anyone else who had found a solution, so I rolled my own. This is a little bit messy, but I''m using in a couple place and can tell you for sure that it works. In the RJS file called first I use page.call to issue a second ajax call. Here is the rjs command I''ve been using: page.call("new Function(\"new Ajax.Request(''/controller/action?qrystring=" +params[:q]+"'', {asynchronous:true, evalScripts:true})\")") Hop this helps. Regards, Aaron --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
There at railsconf europe about reusing bits of rjs. In a nutshell a reasonable way of doing things is via helper functions, a little like so (recalling this from memory): def common_fragment update_page do |page| page.whatever end end Then in your rjs files do page<<common_fragment() Fred -- 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 -~----------~----~----~----~------~----~------~--~---
Fred wrote:> There at railsconf europe about reusing bits of rjs.That should of course say ''There was a talk at railsconf europe'' (by Marcel Molina Jr. slides from talk available at http://project.ioni.st/images/uploads/EuroRailsConf.pdf) Fred -- 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 -~----------~----~----~----~------~----~------~--~---
On 9/21/06, Fred <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > There at railsconf europe about reusing bits of rjs. > In a nutshell a reasonable way of doing things is via helper functions, > a little like so (recalling this from memory): > > def common_fragment > update_page do |page| > page.whatever > end > end > > Then in your rjs files do > page<<common_fragment()Thanks for all the good suggestions guys. I liked them all, but the above appears to be the cleanest. Thanks again! Jake --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---