115
There is no built in method to determine if you have already bound this particular function. You can bind multiple click functions to an object. For example:
$('#id').bind('click', function(){
alert('hello');
});
$('#id').bind('click', function(){
alert('goodbuy');
});
if you do the above when the object is clicked it will alert hello then goodbye. To make sure only one function is bound to the click event unbind the click event handler then bind the desired function like this:
$(obj).unbind('click').bind('click', function(){... });
jQuery makes calling some function possible only once pretty easy:
function someMethod()
{
$(obj).click(function() {});
this.someMethod = $.noop;
}
var bound = false;
function someMethod()
{
if(!bound)
{
$(obj).click(function {});
bound = true;
}
}
but I would probably look into why it;s being called twice before making some kind of workaround.