Hi all, I''ve been using RJS more and more for my app and I have sorta run into a possible issue. My app has different user roles that require different layouts. So far, this has worked fine, but now that I''m using rjs more and more I''m finding that the two don''t really work together since I have to rails not to use a layout upon controller method completion. This isn''t stopping my development and I understand (I think) all the issues regarding this and have so far been able to deal with them. However, I can sorta see where this is all going and the more I rely on rjs, the less I rely on templates. Has anyone else run into any issues re: this and if so, how have you solved them? Thx, jason -- Posted via http://www.ruby-forum.com/.
On 1/11/06, Jason <jasonlee9@gmail.com> wrote:> Hi all, > > I''ve been using RJS more and more for my app and I have sorta run into a > possible issue. My app has different user roles that require different > layouts. So far, this has worked fine, but now that I''m using rjs more > and more I''m finding that the two don''t really work together since I > have to rails not to use a layout upon controller method completion. > > This isn''t stopping my development and I understand (I think) all the > issues regarding this and have so far been able to deal with them. > However, I can sorta see where this is all going and the more I rely on > rjs, the less I rely on templates. > > Has anyone else run into any issues re: this and if so, how have you > solved them? > > Thx, > > jasonSeveral possible solutions: class RjsController < ActionController::Base # Turns off layouts globally, use this for rjs only actions layout nil # specify rjs actions layout nil, :only => [:rjs_edit, :rjs_update] end -- rick http://techno-weenie.net
On Wed, Jan 11, 2006 at 07:15:18PM +0100, Jason wrote:> I''ve been using RJS more and more for my app and I have sorta run into a > possible issue. My app has different user roles that require different > layouts. So far, this has worked fine, but now that I''m using rjs more > and more I''m finding that the two don''t really work together since I > have to rails not to use a layout upon controller method completion.I''m not following entirely. Specifically around: > now that I''m using rjs more > and more I''m finding that the two don''t really work together since I > have to rails not to use a layout upon controller method completion. Should this read, "since I have to *tell* rails not to use a layout upon controller method completion"? And if so what do you mean? When calling actions that render rjs? Layouts are automatically skipped when rendering rjs. Is that not what you mean? Do you mean having to have the rjs update elements which could be in either layout? Shared naming conventions? marcel -- Marcel Molina Jr. <marcel@vernix.org>
Marcel Molina Jr. wrote:> On Wed, Jan 11, 2006 at 07:15:18PM +0100, Jason wrote: >> I''ve been using RJS more and more for my app and I have sorta run into a >> possible issue. My app has different user roles that require different >> layouts. So far, this has worked fine, but now that I''m using rjs more >> and more I''m finding that the two don''t really work together since I >> have to rails not to use a layout upon controller method completion. > > I''m not following entirely. Specifically around: > > > now that I''m using rjs more > > and more I''m finding that the two don''t really work together since I > > have to rails not to use a layout upon controller method completion. > > Should this read, "since I have to *tell* rails not to use a layout upon > controller method completion"? And if so what do you mean? When calling > actions that render rjs? Layouts are automatically skipped when > rendering > rjs. Is that not what you mean? Do you mean having to have the rjs > update > elements which could be in either layout? Shared naming conventions? > > marcelYah, sorry, typo. Should be ''I have to tell..''. I didn''t know that rjs bypassed layouts, but it makes sense. As for rjs updating elements, yeah, and in my case I''ve chosen to have big blocks updated to avoid page refreshes. When I didn''t use rjs, the layouts took care of the obvious in regards to my user roles, which are linked to a particular layout. But now, I''m finding that I have to update more elements when I go from section to section as I''m no longer doing page refreshes. So if, for instance, someone goes from reading some news to then clicking on a link to go to the admin section, my rjs files now how to do multiple element changes/updates. In my case it seems unavoidable which is fine, and I was just wanting to know if anyone else has chosen this path and if they had any examples or thoughts regarding the matter. Thx - jason -- Posted via http://www.ruby-forum.com/.
On Wed, Jan 11, 2006 at 07:40:08PM +0100, Jason wrote:> Marcel Molina Jr. wrote: > > On Wed, Jan 11, 2006 at 07:15:18PM +0100, Jason wrote: > >> I''ve been using RJS more and more for my app and I have sorta run into a > >> possible issue. My app has different user roles that require different > >> layouts. So far, this has worked fine, but now that I''m using rjs more > >> and more I''m finding that the two don''t really work together since I > >> have to rails not to use a layout upon controller method completion. > > > > I''m not following entirely. Specifically around: > > > > > now that I''m using rjs more > > > and more I''m finding that the two don''t really work together since I > > > have to rails not to use a layout upon controller method completion. > > > > Should this read, "since I have to *tell* rails not to use a layout upon > > controller method completion"? And if so what do you mean? When calling > > actions that render rjs? Layouts are automatically skipped when > > rendering > > rjs. Is that not what you mean? Do you mean having to have the rjs > > update > > elements which could be in either layout? Shared naming conventions? > > > > marcel > > So if, for instance, someone goes from reading some news to then > clicking on a link to go to the admin section, my rjs files now how to > do multiple element changes/updates. In my case it seems unavoidable > which is fine, and I was just wanting to know if anyone else has chosen > this path and if they had any examples or thoughts regarding the matter.Using Ajax (and in this case rjs) for this kind of site navigation can have some shortcomings from a usability stand point. Users don''t have access to a uri so they can''t link to or bookmark or otherwise get directly to a part of your site without clicking one or more times. marcel -- Marcel Molina Jr. <marcel@vernix.org>
Marcel Molina Jr. wrote:> On Wed, Jan 11, 2006 at 07:40:08PM +0100, Jason wrote: >> > > now that I''m using rjs more >> > >> > marcel >> >> So if, for instance, someone goes from reading some news to then >> clicking on a link to go to the admin section, my rjs files now how to >> do multiple element changes/updates. In my case it seems unavoidable >> which is fine, and I was just wanting to know if anyone else has chosen >> this path and if they had any examples or thoughts regarding the matter. > > Using Ajax (and in this case rjs) for this kind of site navigation can > have > some shortcomings from a usability stand point. Users don''t have access > to a > uri so they can''t link to or bookmark or otherwise get directly to a > part of > your site without clicking one or more times. > > marcelRight and for my usage, these things are ok as most of this is under a logged in umbrella and we''re ok with bookmarking not working at this level. Hopefully there will be more examples of people using rjs so I can get a better feel of other ways it''s being used. -j -- Posted via http://www.ruby-forum.com/.
> But now, I''m finding that I have to update more elements when I go > from section to section as I''m no longer doing page refreshes. > > So if, for instance, someone goes from reading some news to then > clicking on a link to go to the admin section, my rjs files now how > to do multiple element changes/updates.This seems like an overuse of RJS. Navigating from page to page in an application still has some value, even in the bright shiny new age of Web 2.0 and Ajax. The Back button remains a user''s best friend; it sounds like you''re effectively redrawing whole pages using RJS, which will break the user''s own page history. It''s as bad as doing everything in one big frameset. Come to think of it, how would you handle it if the user clicks the browser Refresh button? Wouldn''t you lose the state of your page, which might have been constructed by several RJS calls?