How to unbind an event defined by a global function?

I have an event binded to a global function (I need it to keep track of the function itself).


 window['mUpEventHandler'] = function(){
      // ...

It's binded to $('body') via


Now I know that I can unbind it knowing the name of the handler as in

 $('body').off(myHandler) // # myHandler = mUpEventHandler  for example

However when defining it globally, I have the function itself but not its name.

How do I overcome this?


Can you bind using a namespace. Then remove the event based off the namespace?

window['mUpEventHandler'] = function () {

$('body').on('mouseup.mUpEventHandler', function () {

$('button').click(function () {

In $('body').off(myHandler), myHandler is not a "name", it's a variable that references a function.

To unbind an event handler you need a reference to the function. So

// or

will work just fine.

Need Your Help

Relational database regarding two tables

mysql database

Is it advisable to have table A having two foreign keys from table B? My thinking is that if one of the foreign key in table A is a primary key, then there is no need to add additional foreign key in

C where to define a mutex in a multithread program?

c multithreading unix mutex semaphore

I am working on a multi-thread program, and have a question about where to define the mutex.