RJS and layouts


#1

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


#2

On 1/11/06, Jason removed_email_address@domain.invalid 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


#3

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


#4

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

#5

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


#6

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