3

Possible Duplicate:
test if event handler is bound to an element in jQuery

I have a button with a fairly large script attached to it. I'm binding to this button like so:

 $(document).on( "click", '.basketSubmitter' , function(e) {

 ... stuff

 });

I can't pin it down, but sometimes the button looses it's binding = I click all I want and nothing happens. The buttons sitting left and right continue to work fine, so there must be something with the button being unbound somewhere. Script is large, so

Question:
Is there an easy way to list an elements binding or to detect when an element looses bindings in Jquery?

Thank!

Community
  • 1
  • 1
frequent
  • 27,643
  • 59
  • 181
  • 333
  • It's seems this was previously asked here and it's solved: http://stackoverflow.com/questions/4138543/list-all-bindings-of-an-elment-with-jquery – spekdrum Oct 18 '12 at 10:18
  • see this question (i guess its for debugging purposes) http://stackoverflow.com/questions/1236067/test-if-event-handler-is-bound-to-an-element-in-jquery – davidkonrad Oct 18 '12 at 10:18
  • You could try to use namespaced events to prevent canceling/unbinding the click event from somewhere else: http://api.jquery.com/on/#event-names – feeela Oct 18 '12 at 10:19
  • is it possibly due to errors thrown under certain conditions? look in console – charlietfl Oct 18 '12 at 10:52
  • @charlietfl: checked the console on Firebug and iPad - no errors. Strangely the binding is only "lost" on iPad... But if it was from some memory issue, no buttons should work. – frequent Oct 18 '12 at 11:00

2 Answers2

1

This tool will help you to find out the binded events to any DOM element

http://www.sprymedia.co.uk/article/Visual+Event+2

It's good if you want to inspect the dom to find binded events..

udidu
  • 8,269
  • 6
  • 48
  • 68
1

Try namespacing your event. For eg click.myFunc

That can be used as

$('.basketSubmitter').off('click.myFunc')on( "click.myFunc" , function(e) {

 ... stuff

 });
Ankur
  • 791
  • 4
  • 15