Having click handlers added repeteadly is a sign of bad structure in
your code. You should refactor your code to avoid that in the first
place, that should'nt be happening.

That said, there is a way to check for event handlers:

var $login = $('#login');
if ( jQuery.data( $login[0], "events").click ){
  // there is a handler already
} else {
  $login.click( fn );
};

If you're staying with the unbind solution, add a namespace so you
only unbind the relevant events, not all of them (in case they exist):

$('#login').bind('click.sken', function(){...});
$('#login').unbind('click.sken');

On Jul 21, 4:59 am, sken <skendlbac...@googlemail.com> wrote:
> Hey,
> is it possible to get the "binding" of an object.
> Let`s say i do
>
> $("#login").click(function);
>
> so the next time i call $("#login") i want to check if a click event
> is already bind to that obejct.
> So that i don't have a double binding (in this case the click is
> doubletriggered)
>
> My solution was to unbind it.
>
> $("#login").unbind("click").click(function);
>
> This does work but i was just curious if there is another possibility
> to check this.

Reply via email to