This plugin helps to include javascript and stylesheets only when you
need
to.
Currently if you want the :defaults javascripts to be included, you
include
them in the layout and they are called in in all pages that use that
layout,
even if it’s essentially a javascript static page.
With this you can specify that a layout, or a deeply nested partial
requires
a particular javascript file, or stylesheet. This will be then included
in
the head tag of the layout without duplicates. eg you can have a
partial
iterating over a collection that calls a particular js file every
iteration,
but only one javascript_include_tag call will be made for that file.
From the README
= resource_on_demand
Allows inclusion of external javascript and stylesheets in the head tag,
from anywhere in a view, including nested partials
def require_page_support(*scr)
Then, in my layout, I have things like this, for example for lightbox:
require_page_support :lightbox
opts.merge!(:class => ‘lbOn’)
link_to(content, action, opts)
end
If any of this is any use, feel free to pinch it.
Thanx for the input. Now that I’ve had a sleep on it I’m not sure that
I’m
cool with the method names that I used. I think I may change these to
require_javascript instead of demand_javascript.
I’ll have a good look at how your helper methods work when I get home.
Cheers
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.