Generic page element display initializer in a layout?

All,

I’ve run into a snag. I need to handle the display of elements on my
page and I want to use my Javascript event handlers on page load.

However, my BODY tag is trapped in my generic layout.

I’m thinking that I can put an onLoad on the BODY tag that will just
call a Javascript method called initializePage() and then provide this
initializePage() call in my specific page to call whatever handlers I
need to in order to display things correctly.

Something in the back of my head is screaming AJAX but not sure how I
would get that in.

Any thoughts?

Wes

Wes G. wrote:

All,

I’ve run into a snag. I need to handle the display of elements on my
page and I want to use my Javascript event handlers on page load.

However, my BODY tag is trapped in my generic layout.

I’m thinking that I can put an onLoad on the BODY tag that will just
call a Javascript method called initializePage() and then provide this
initializePage() call in my specific page to call whatever handlers I
need to in order to display things correctly.

Something in the back of my head is screaming AJAX but not sure how I
would get that in.

Any thoughts?

Wes

FYI, this kind of Javascript scheme will work, but I think I just need
to make my template smarter, so I will do that instead.

WG

On Jul 13, 2006, at 10:04 AM, Wes G. wrote:

this
FYI, this kind of Javascript scheme will work, but I think I just need
to make my template smarter, so I will do that instead.

WG

Wes-

You can also use the content_for  method to push dynamic content

from your view up to the master layout.

So in your normal view:

<% content_for :javascript do %>

# blah blah more javascript <% end %> So in your layout: <%= yield :javascript %> -Ezra

Ezra Z. wrote:

On Jul 13, 2006, at 10:04 AM, Wes G. wrote:

this
FYI, this kind of Javascript scheme will work, but I think I just need
to make my template smarter, so I will do that instead.

WG

Wes-

You can also use the content_for method to push dynamic content
from your view up to the master layout.

So in your normal view:

<% content_for :javascript do %>

# blah blah more javascript <% end %> So in your layout: <%= yield :javascript %> -Ezra

Whoa - so content_for generates a block that can then be yielded to in
any of the enclosing templates?

WG

On Jul 13, 2006, at 1:22 PM, Wes G. wrote:

-Ezra

Whoa - so content_for generates a block that can then be yielded to in
any of the enclosing templates?

WG

Wes-

Yeah, pretty sweet way to push dynamic content up from the partials

or templates into the layout. This is a very powerfull feature once
you start playing with it. Makes your layouts much more flexible and
reuseable because your normal views can specialize the layout.

Cheers-
-Ezra

Ezra Z. wrote:

On Jul 13, 2006, at 1:22 PM, Wes G. wrote:

-Ezra

Whoa - so content_for generates a block that can then be yielded to in
any of the enclosing templates?

WG

Wes-

Yeah, pretty sweet way to push dynamic content up from the partials
or templates into the layout. This is a very powerfull feature once
you start playing with it. Makes your layouts much more flexible and
reuseable because your normal views can specialize the layout.

Cheers-
-Ezra

As I sometimes say when I get excited - that is f-in ballz!

:slight_smile:

WG