Reputation: 2344
I am using the following with an address picker.
HTML
<form>
<input id="searchByLoc" type='checkbox' >
<input id="searchQuery" type='text' >
<input type="submit' value="search">
</form>
JQuery:
$('#searchByLoc:checkbox ').live('change', function(){
if($(this).is(':checked')){
var addresspicker=$(this).addresspicker();//alert('checked');
} else {
//I want to un initialize the addresspicker() on the input field
var addresspicker=die($(this).addresspicker());//alert('un-checked');
}
});
I am having some trouble with the ELSE part above. If the check box is unchecked, how can I stop the initialization so that no location is suggested?
Upvotes: 0
Views: 263
Reputation: 15861
Use unbind() function of jquery. It will remove the event. jquery bind
You can see this post also for best usage best way to remove events
below jquery 1.7
$('#yourDomElement').unbind('click');
jquery 1.7+
$('#yourDomElement').off('click');
Upvotes: 2