I have a toolbar that manipulates a Google map. Some of the functions affect markers placed on the map. I have a reset button that clears the changes and returns the map to the original state.
I need to "disable" the reset button until the map is changed. So...
- When an action is completed that manipulates the map, I bind the ResetMap() function to the reset button.
- Reset button is clicked and returns the map to original state.
- Reset button action is unbound again.
However, I can't get step 3 to work. I tried to unbind the event at the end of the ResetMap() function like so:
function ResetMap(){
var Wrapper = $("#page_layout").find("#InlineToolbarMessages");
if(Wrapper.hasClass('isExpanded')){
Wrapper.removeClass('isExpanded');
Wrapper.addClass('isCollapsed');
}
$("#page_layout").find('#NumSelectedNumber').html("0");
$("#page_layout").find('div#SelectedVoters').html("");
clearMarkers();
$('#page_layout').find('#reset_button').unbind('click', function(){
ResetMap();
});
}
I also tried a more global:
$('#page_layout').find('#reset_button').unbind();
without success. What am I doing wrong?