Basically, a layout wraps various snipits of html body-element code with a constant-content wrapper. Accordingly, it is the layout that contains the html <head> element associated with the respective snipits and the <head> element is the same for all such snipits. I seem to be encountering a variety of cases where I would like to have specific javascript code and/or styles (which I would ordinarily place in the html <head> element) apply only to one specific html snipit of many such snipits that share a common <head> element. I am wondering how others are approaching this situation. Thanks for any input. ... doug --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Basically, a layout wraps various snipits of html body-element code > with a constant-content wrapper. Accordingly, it is the layout that > contains the html <head> element associated with the respective > snipits and the <head> element is the same for all such snipits. I > seem to be encountering a variety of cases where I would like to have > specific javascript code and/or styles (which I would ordinarily place > in the html <head> element) apply only to one specific html snipit of > many such snipits that share a common <head> element. I am wondering > how others are approaching this situation. Thanks for any input.layout: --------------------------------------------------- <html> <head> <%= yield :page_header %> </head> <body> <%= yield %> </body> </html> --------------------------------------------------- view: --------------------------------------------------- <% content_for ''page_header'' do %> javascript includes, stylesheet includes, raw javascript, etc. <% end %> blah blah --------------------------------------------------- I''d also suggest having a "end_of_body" yield so you can easily insert javascript that must go right before the closing <body> tag. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> layout: > > --------------------------------------------------- > <html> > <head> > <%= yield :page_header %> > </head> > <body> > <%= yield %> > </body> > </html> > --------------------------------------------------- > > view: > > --------------------------------------------------- > <% content_for ''page_header'' do %> > javascript includes, stylesheet includes, raw javascript, etc. > <% end %> > > blah blah > ---------------------------------------------------Perfect. Exactly what I wanted to know. Thanks! :) ... doug --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I was so lucky with the answer to my first question that I thought I would press further into a related aspect that is also troubling me. I often want to launch a JavaScript when a particular page loads. The typical way that I do this is by including an onload event handler in the opening <body> tag for the page. If the particular page in question happens to be formed by embedding a snippet of html code in a layout there may be a problem in that the body tag is typically in the layout and therefore shared with other pages similarly formed and for which I do not want to launch the JavaScript. Anyone have a good way of handling this? Thanks. ... doug --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---