i’ve written script function ganesh.js inside “public/javascripts/”
path…
ganesh.js…
function gan()
{
alert(‘hai’);
}
ive called that function in show.rhtml file like
<%= image_tag(‘e.image’, {:id => e.id, :onload => gan()}) %>
i cant able to call that function …is there any other way to enable
javascript function in ruby rails…pls help…
if i wrote script inside rhtml its working …
<%=link_to_function(“add”,“gan()”)%>
how to enable javascript function from public/javascripts folder…
On 11 Jul 2008, at 09:45, Jai zenag wrote:
ive called that function in show.rhtml file like
<%= image_tag(‘e.image’, {:id => e.id, :onload => gan()}) %>
that would need to be
<%= image_tag(‘e.image’, {:id => e.id, :onload => “gan()”}) %>
You would need to include the relevant javacript file using
javascript_include_tag
Fred
It may be one of the following two reasons for getting the problem.
-
You have not included the relevant javascript in the rhtml file.
The following statement should be there in the rhtml file.
<%= javascript_include_tag ‘ganesh.js’ %>
-
You have not called the javascript method inside quotes.
Try with,
<%= image_tag(‘e.image’, {:id => e.id, :onload => “gan();”}) %>
THANK U VERY MUCH Karthi …IT WORKS FINE…