events - how to unbind and bind again -


$("#archive").click(function(event){         /*do something*/ });  $('#archive2').unbind('click',event); 

i have click function unbind. however, want bind again when click button.

$("#archive").bind("click",event); 

im using code bind again, doesn't seem work. suggestions or workarounds?

you have keep reference function (instead of passing anonymous function):

function handler() {     // }  $("#archive").click(handler); // bind first time $("#archive").unbind('click', handler); // unbind $("#archive").click(handler); // bind again 

not sure event in case, if event object passed event handler not make sense pass unbind , bind.


Comments