On Jun 2, 2009, at 2:23 PM, Tyler Knappe wrote:
>
> Hey All,
>
> I'm trying to call a javascript function from my view:
>
> <%= link_to_function 'Next Week Test', "testjs()" %>
>
> Which *should* be calling this:
>
> <script type="text/javascript">
> var next_week = 0;
> function testjs()
> {
> //next_week = next_week + 1;
> alert('Next week' + next-week);
> //return next_week;
> }
> </script>
>
> I've included /public/javascripts/test.js in my layout, it shows up as
> included in the source of the page:
>
> <script src="/javascripts/test.js?1243524559"
> type="text/javascript"></script>
>
> However, it never seems to call the function resulting in the alert.
>
> Anyone see something wrong?
alert('Next week' + next-week);
^^^^^^^^^
That should be "next_week".
Odds are you're getting a JS error, but not seeing it. Turn on
whatever debugging you might have (firebug in firefox, or safari's
debug inspector) and it will make this easy to catch.
-philip
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---