Jonathan Viney
2006-May-25 01:33 UTC
[Rails] Is there a way to abstract the updating of other parts of the page after an Ajax request without putting using the standard view file?
Hey all, I''d like to abstract the process of updating different portions of the page after an Ajax request has taken place. Rather than simply putting the extra view logic in the standard rjs template, it seems to give better separation if there is a split between the core view logic (ie, inserting a row in a table), and updating any associated portions of the page. Is this possible? I can''t see a way of doing it at the moment because render can only be called once. I could just fiddle with the RJS stuff in ActionView but would like to check there isn''t a better way. Maybe an after_filter, but I''m doubtful about that. Thanks, -Jonathan.
Daniel Higginbotham
2006-May-25 02:05 UTC
[Rails] Is there a way to abstract the updating of other parts ofthe page after an Ajax request without putting using thestandard view file?
I''m not sure if you can do this with an RJS template, but you should be able to create a response to an ajax request which contains more ajax requests which are then executed. I''m sorry this doesn''t give you anything concrete, but I hope it helps Daniel -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Jonathan Viney Sent: Wednesday, May 24, 2006 3:33 PM To: Rails Subject: [Rails] Is there a way to abstract the updating of other parts ofthe page after an Ajax request without putting using thestandard view file? Hey all, I''d like to abstract the process of updating different portions of the page after an Ajax request has taken place. Rather than simply putting the extra view logic in the standard rjs template, it seems to give better separation if there is a split between the core view logic (ie, inserting a row in a table), and updating any associated portions of the page. Is this possible? I can''t see a way of doing it at the moment because render can only be called once. I could just fiddle with the RJS stuff in ActionView but would like to check there isn''t a better way. Maybe an after_filter, but I''m doubtful about that. Thanks, -Jonathan. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
Daniel N
2006-May-25 02:15 UTC
[Rails] Is there a way to abstract the updating of other parts of the page after an Ajax request without putting using the standard view file?
is there anything wrong with page.replace_html id, :partial => ''somePartial'' ? On 5/25/06, Jonathan Viney <jonathan.viney@gmail.com> wrote:> > Hey all, > > I''d like to abstract the process of updating different portions of the > page after an Ajax request has taken place. Rather than simply putting > the extra view logic in the standard rjs template, it seems to give > better separation if there is a split between the core view logic (ie, > inserting a row in a table), and updating any associated portions of > the page. > > Is this possible? I can''t see a way of doing it at the moment because > render can only be called once. I could just fiddle with the RJS stuff > in ActionView but would like to check there isn''t a better way. > > Maybe an after_filter, but I''m doubtful about that. > > Thanks, -Jonathan. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060525/23319985/attachment.html
Jonathan Viney
2006-May-25 03:53 UTC
[Rails] Is there a way to abstract the updating of other parts of the page after an Ajax request without putting using the standard view file?
Yep, that''s what I''m doing at the moment. The reason I want the separation is that the application relies heavily on Ajax so there are often quite a number of page areas that need to be changed. It would be nice to be able to separate the updating code from the rest of the rjs code. -Jonathan On 5/25/06, Daniel N <has.sox@gmail.com> wrote:> is there anything wrong with > page.replace_html id, :partial => ''somePartial'' > > ? > > > On 5/25/06, Jonathan Viney < jonathan.viney@gmail.com> wrote: > > > Hey all, > > I''d like to abstract the process of updating different portions of the > page after an Ajax request has taken place. Rather than simply putting > the extra view logic in the standard rjs template, it seems to give > better separation if there is a split between the core view logic (ie, > inserting a row in a table), and updating any associated portions of > the page. > > Is this possible? I can''t see a way of doing it at the moment because > render can only be called once. I could just fiddle with the RJS stuff > in ActionView but would like to check there isn''t a better way. > > Maybe an after_filter, but I''m doubtful about that. > > Thanks, -Jonathan. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Daniel N
2006-May-25 09:42 UTC
[Rails] Is there a way to abstract the updating of other parts of the page after an Ajax request without putting using the standard view file?
I''m not sure that I understand the distinction your trying to make. Could what your trying to achive be done by calling render on a partial rjs which replaces particular areas (or has a particular branch of logic) with another rjs partial? ie render :partial => ''branch_one'' _branch_one.rjs if some logic page.replace_html "thing1", :partial =>''branch_two'' page.replace_html "thing2", :partial =>''branch_three'' else page.replace_html "thing1", :partial =>"branch4" page.replace_html "thing2", :partial => "branch5" end then you could similarly have logic dedicated to other branches in the partials _branch_two.rjs _branch_three.rjs _branch4.rjs _branch5.rjs I''m not sure that this is what you had in mind tho.. On 5/25/06, Jonathan Viney <jonathan.viney@gmail.com> wrote:> > Yep, that''s what I''m doing at the moment. > > The reason I want the separation is that the application relies > heavily on Ajax so there are often quite a number of page areas that > need to be changed. It would be nice to be able to separate the > updating code from the rest of the rjs code. > > -Jonathan > > On 5/25/06, Daniel N <has.sox@gmail.com> wrote: > > is there anything wrong with > > page.replace_html id, :partial => ''somePartial'' > > > > ? > > > > > > On 5/25/06, Jonathan Viney < jonathan.viney@gmail.com> wrote: > > > > > Hey all, > > > > I''d like to abstract the process of updating different portions of the > > page after an Ajax request has taken place. Rather than simply putting > > the extra view logic in the standard rjs template, it seems to give > > better separation if there is a split between the core view logic (ie, > > inserting a row in a table), and updating any associated portions of > > the page. > > > > Is this possible? I can''t see a way of doing it at the moment because > > render can only be called once. I could just fiddle with the RJS stuff > > in ActionView but would like to check there isn''t a better way. > > > > Maybe an after_filter, but I''m doubtful about that. > > > > Thanks, -Jonathan. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060525/6a3585e4/attachment.html
Chris Hall
2006-May-25 11:07 UTC
[Rails] Is there a way to abstract the updating of other parts of the page after an Ajax request without putting using the standard view file?
you also have the option of rendering the rjs directly within the action def some_action if request.xhr? render :update do |page| case @param[:do] when ''foo'' page.replace_html ... when ''bar'' page.replace_html ... end end end On 5/25/06, Daniel N <has.sox@gmail.com> wrote:> > I''m not sure that I understand the distinction your trying to make. > > Could what your trying to achive be done by calling render on a partial > rjs which replaces particular areas (or has a particular branch of logic) > with another rjs partial? > > ie > > render :partial => ''branch_one'' > > _branch_one.rjs > if some logic > page.replace_html "thing1", :partial =>''branch_two'' > page.replace_html "thing2", :partial =>''branch_three'' > else > page.replace_html "thing1", :partial =>"branch4" > page.replace_html "thing2", :partial => "branch5" > end > > then you could similarly have logic dedicated to other branches in the > partials > _branch_two.rjs > _branch_three.rjs > _branch4.rjs > _branch5.rjs > > I''m not sure that this is what you had in mind tho.. > > > On 5/25/06, Jonathan Viney <jonathan.viney@gmail.com> wrote: > > > > Yep, that''s what I''m doing at the moment. > > > > The reason I want the separation is that the application relies > > heavily on Ajax so there are often quite a number of page areas that > > need to be changed. It would be nice to be able to separate the > > updating code from the rest of the rjs code. > > > > -Jonathan > > > > On 5/25/06, Daniel N <has.sox@gmail.com> wrote: > > > is there anything wrong with > > > page.replace_html id, :partial => ''somePartial'' > > > > > > ? > > > > > > > > > On 5/25/06, Jonathan Viney < jonathan.viney@gmail.com> wrote: > > > > > > > Hey all, > > > > > > I''d like to abstract the process of updating different portions of the > > > page after an Ajax request has taken place. Rather than simply putting > > > the extra view logic in the standard rjs template, it seems to give > > > better separation if there is a split between the core view logic (ie, > > > inserting a row in a table), and updating any associated portions of > > > the page. > > > > > > Is this possible? I can''t see a way of doing it at the moment because > > > render can only be called once. I could just fiddle with the RJS stuff > > > in ActionView but would like to check there isn''t a better way. > > > > > > Maybe an after_filter, but I''m doubtful about that. > > > > > > Thanks, -Jonathan. > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060525/4046a6d5/attachment.html