Jquery how to untrigger a function -


i'm creating dynamic form. have dropdown list when user makes selection, database queried see if item required privacy or not. if doesn't additional fields added form. zip code lookup ajax function triggered, should triggered if item not private.

this working fine, until user changes mind...

here relevant part of code runs when ever item selected dropdown;

success:function(response){     if(response === '1'){         // stuff item requires privacy         // not trigger zip_check function     }else if(response === '0'){         // stuff item public +         $('#zip-code').keyup(zip_check); // triggers function check zip code     } } 

this works expected until user selects non private item changes mind , selects private item in case zip_check function still run though shouldn't getting triggered. going wrong?

i think looking off (add in (response===1){} ):

$('#zip-code').off('keyup', zip_check); 

this way remove function click event. if want events removed, use

$('#zip-code').off('keyup'); 

if want events off:

$('#zip-code').off(); 

.off() prefered method on .unbind(), , .on() .bind()


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -