Forum: Ruby on Rails RJS and layouts

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9a5c497293dffb91cacef202bad5b602?d=identicon&s=25 Jason (Guest)
on 2006-01-11 19:15
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
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2006-01-11 19:24
(Received via mailing list)
On 1/11/06, Jason <jasonlee9@gmail.com> wrote:
> 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

Several 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
Cee0292fffa691f1fb320d5400200e99?d=identicon&s=25 Marcel Molina Jr. (Guest)
on 2006-01-11 19:30
(Received via mailing list)
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
9a5c497293dffb91cacef202bad5b602?d=identicon&s=25 Jason (Guest)
on 2006-01-11 19:40
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

Yah, 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
Cee0292fffa691f1fb320d5400200e99?d=identicon&s=25 Marcel Molina Jr. (Guest)
on 2006-01-11 20:44
(Received via mailing list)
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.

marcel
9a5c497293dffb91cacef202bad5b602?d=identicon&s=25 Jason (Guest)
on 2006-01-11 21:32
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.
>
> marcel

Right 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
This topic is locked and can not be replied to.