If I need to assign a click function dynamically, is there a way to ensure the click function is only assigned once and not duplicated?
this.click(function(){
alert('test');
})
If I need to assign a click function dynamically, is there a way to ensure the click function is only assigned once and not duplicated?
this.click(function(){
alert('test');
})
You can unbind the click event before you bind it again, that way you will only have one event attached to it:
//assuming this is a jquery object.
this.unbind("click");
this.click(function(){
alert("clicked once");
});