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?
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
jquery 1.7+