The obvious solution is to not call someMethod() twice. If you can't fix that, then you can keep a state variable so it only ever binds once like this:
function someMethod()
{
if (!someMethod.bound) {
$(obj).click(function() {});
someMethod.bound = true;
}
}
Note: this uses a property of the function itself rather than introducing a global variable to keep track of whether it's been bound. You could also use a property on the object itself.
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:
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:
This is a suggestion since I do not know your logic. May or may not work for you.
Try combining jquery live() and one() functions will give you a better result than event rebinds.
The special cases work when you have 2 DOM elements (parent & child). Live() at parent node makes sure event will be invoked, and then calls one() to dynamically register event which would be executed only once. (this provides similar functionality like rebinds).
Notice that the extension works by checking both uid and type. This means that you can bind different types of handlers with the same uid, you may or may not want this. To change it edit.
I was also trying to use off and on method of jquery for binding event only once with the dom element which does not exists yet or the dom element is not yet created.