[stackoverflow] unbind event

3949394/jquery-bind-problem

by danmana

HTML

<input id="btn" type="button" value="Button">

JavaScript

$('#btn').bind('myEvent',function(){
    alert('myEvent.other plugins');
});

$('#btn').bind('myEvent.myPlugin',function(){
    alert('myEvent.myPlugin');
});

//use this in your loadDialod function for the dialogClose event
//bind the event the second time, but remove the ond bindings
//will leave any bindings done by other plugins alone
$('#btn').unbind('myEvent.myPlugin').bind('myEvent.myPlugin',function(){
    alert('myEvent.myPlugin');
});

$('#btn').trigger('myEvent');