Reputation: 7536
I am beginner to ruby on rails what I want to do in my application is call java script function from script define inside view file like in following manner
//code inside js file ...
$(document).ready(function() {
alert("outside the function");
function abc()
{
alert("inside function");
}
});
//code in side view file
<div> creating view here </div>
<script type="text/javascript" language="javascript">
abc();
</script>
But It not giving require output. It shows one alert i.e. outside the function. But not showing other one that mean not calling that function. I want to call that function ... How to do this? Any solution? Need help ... Thank you ....
Upvotes: 0
Views: 984
Reputation: 17910
Try this, you need to move your function abc()
outside the jQuery ready
wrapper function.
$(document).ready(function() {
alert("outside the function");
});
function abc(){
alert("inside function");
}
Upvotes: 3