I have created a js file which has a function.
When I call that function on $(document).ready; it is not working.
I checked through firebug, It is calling the function but not going into the function.
Here is my JavaScript code:
function toggelEventButtons() {
var invoiceVal = $('#Invoice_Id').val(); //It is a textbox Id of aspx Page.
alert(invoiceVal);
if (invoiceVal > 0) {
$('#addEventInvoiceDetail').hide();
$('#editEventInvoiceDetail').show();
} else {
$('#addEventInvoiceDetail').show();
$('#editEventInvoiceDetail').hide();
}
}
I call the function from an aspx page like this:
$(document).ready(toggelEventButtons);
-
Is the function definition at toplevel, or inside another function?Barmar– Barmar2013年04月11日 08:37:58 +00:00Commented Apr 11, 2013 at 8:37
-
It is independent. Not inside another function.Dhwani– Dhwani2013年04月11日 08:38:38 +00:00Commented Apr 11, 2013 at 8:38
-
What do you mean by "it is calling function but not going into the function"?David Hedlund– David Hedlund2013年04月11日 08:39:33 +00:00Commented Apr 11, 2013 at 8:39
-
1Make sure that you included file with function before calling $(document).ready().Artem Vyshniakov– Artem Vyshniakov2013年04月11日 08:40:16 +00:00Commented Apr 11, 2013 at 8:40
-
that function is on other js script? did you forget to include it?Bojan Kovacevic– Bojan Kovacevic2013年04月11日 08:40:18 +00:00Commented Apr 11, 2013 at 8:40
2 Answers 2
Make sure that you included file with a function before calling $(document).ready().
answered Apr 11, 2013 at 8:44
Artem Vyshniakov
16.5k3 gold badges46 silver badges48 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
David Hedlund
Incidentally, since this was the problem, it means that the solution
$(function() { toggelEventButtons(); }); would in fact have helped. It would not, perhaps, have been the neatest solution to the problem, though :)make sure the functions are on the same scope. you can also try this syntax
$(document).ready(function(){ toggelEventButtons() });
Comments
lang-js