سؤال

I am having a problem with my code

if (text.length < 1)

       {
           args.IsValid = false;
           $('#<% = cmdSaveRequest.ClientID()> %>').removeAttr('click'());

       }
       else 
       {

           $('#<% = cmdSaveRequest.ClientID()> %>').click(savingData());
           args.IsValid = true;
       } 

when I assign click event like

$('#<% = cmdSaveRequest.ClientID() %>').click(savingData());

it executes the saving data function Is there any way to bind the click event to button but whiteout executing the function just bind it and after user clicks the button then the function executes?

هل كانت مفيدة؟

المحلول

Try

$('#<% = cmdSaveRequest.ClientID() %>').click(savingData);

No paranthesis by savingData

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top