Reputation: 1
If I am using statement:
`$`.link_to_function "Greeting", "alert('Hello world!')", :class => "nav_link"
It's working fine.
But If
`$`.link_to_function "Greeting", "my_function", :class => "nav_link"
I have defined my_function in application.js
`$`.function my_function(){
alert("my function called");
}
I am using rails 3.2.1
Thanks in advance, Ashish
Upvotes: 0
Views: 226
Reputation: 16064
JavaScript function calls must always include parenthesis, even if they have no arguments. So try this:
`$`.link_to_function "Greeting", "my_function()", :class => "nav_link"
Upvotes: 1