1

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);
Nope
22.4k8 gold badges50 silver badges73 bronze badges
asked Apr 11, 2013 at 8:36
8
  • Is the function definition at toplevel, or inside another function? Commented Apr 11, 2013 at 8:37
  • It is independent. Not inside another function. Commented Apr 11, 2013 at 8:38
  • What do you mean by "it is calling function but not going into the function"? Commented Apr 11, 2013 at 8:39
  • 1
    Make sure that you included file with function before calling $(document).ready(). Commented Apr 11, 2013 at 8:40
  • that function is on other js script? did you forget to include it? Commented Apr 11, 2013 at 8:40

2 Answers 2

2

Make sure that you included file with a function before calling $(document).ready().

answered Apr 11, 2013 at 8:44
Sign up to request clarification or add additional context in comments.

1 Comment

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 :)
1

make sure the functions are on the same scope. you can also try this syntax

$(document).ready(function(){ toggelEventButtons() });
answered Apr 11, 2013 at 8:40

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.