Here's what I ended up with based on the advice from irc.

I"m using haml for my templates.  So in my layout, e.g.,
application.html.haml, I have this in my header section:

   - require_js 'jquery.js', 'application.js'
   = include_required_js
   - require_css 'application.css'
   = include_required_css
   = catch_content :custom_js

The key part, is the last line, just showing you where it fits
relative to other stuff.  haml handles wrappering of javascript very
nicely, this is cleaner than prior examples you may find.

Then in any template, throw the content, like so:

   - throw_content :custom_js do
      :javascript
         // my custom_js
         $(document).ready(function($) {
         });

hope this help, Jon

On Sep 4, 12:27 pm, toxy <[email protected]> wrote:
> Could you, guys, copy-paste it here or point me to discussion log?
> That is interesting.
>
> On Sep 4, 3:37 pm, Pavel Kunc <[email protected]> wrote:
>
> > Hi Jon, did we solve it on the IRC?
>
> > Pavel
>
> > On Sep 3, 6:58 pm, Jon Hancock <[email protected]> wrote:
>
> > > I have been using  require_js for a while, but only in my main layout
> > > and sometimes requiring things per template, but hard coded in ways
> > > that aren't maintainable for doing it for every page in my app.
>
> > > In this new app, I"m going to drive each page with js.  I need to add
> > > bit of js specific to drive each page.  I don't see how I'm supposed
> > > to do this.
>
> > > Mostly it would be page specific script like so:
>
> > > <script>
> > >   $(document).ready(function() {
> > >         my code_here});
>
> > > </script>
>
> > > What do others do?
>
> > > thanks, Jon
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to