thanks all for the advice.  The string substitution seems to be
working.
Jon

On Nov 10, 10:26 am, Tony Mann <[email protected]> wrote:
> I put most of my JS in separate files, one for each controller, or for each
> controller/view when they get more involved.
>
> To pass in info from the controller. I use two approaches. One is via
> onclick handler with interpolation. The handler consists of a single
> function call so its fairly clean.
>
> When I want to pass data to several functions more unobtrusively, I set a JS
> global variable via a helper:
>
> def js_set_var(name, val)
>       "<script type=\"text/javascript\">var #{name} =
> #{val.to_json};</script>"
> end
>
> Both approaches work well for me.
>
> ..tony..
>
>
>
> On Mon, Nov 9, 2009 at 8:43 PM, Jon Hancock <[email protected]> wrote:
>
> > Here's my problem:  I'm using haml templates.  Haml has a nice tag for
> > embedding javascript.  So I can have a template that look like so:
>
> > %h1 my page
> > #someDiv
> > :javascript
> >    window.addEvent('domready', function(){
> >        // do some cool stuff
> >    });
>
> > This allows me quite a bit of freedom.  However, what do I do when the
> > javascript needs some parameters, for example some variable from my
> > controller?  I can't do this as the haml javascript embedding is
> > literal.
>
> > I have been thinking about a merb helper so I could write the above
> > as:
>
> > %h1 my page
> > #someDiv
> > = javascriptHelper
> >    window.addEvent('domready', function(){
> >        // do some cool stuff WITH PARAM PARSING ON THIS CONTENT
> >    });
>
> > But I don't see how this can be done.  Any ideas on how to make this
> > easy?  The current helpers I'm writing are horrific javascript string
> > concatenation nightmares.
>
> > 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