On Feb 15, 2012, at 9:56 PM, Chris McCann wrote:
> There are three groups of controls that need this treatment on the
> same page, and it seems awkward to me to be making reference to three
> specific ID and class selectors that only appear on one page in JS
> code that's loaded on every page in the app.
Such matters are best handled by giving the things you want to treat the same
an identical class, and then if need be, adding anything specific to the
elements as data-elements that a JQuery script can then hook into. You know an
element can have any number of classes, right?
You can just load a specific JS file on the pages that need this treatment. Or
it sounds like you might have just a line or two of JS you need to run on these
pages. In that case, I think a few lines of JS embedded in the page itself is
just fine. I generally have $(function(){<%= yield :startup %>}) and
<script><%= yield :scripts %></script> in the footer of my templates for this
reason.
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby