I am using JQuery .live to listen for a custom event, ie not .click, .change, .keyup or any of the native events, but rather an event that I create using jquery .trigger. I have several places in the application that listen for this event using .live. I want to remove a single handler from the event. None of the methods I've tried seem to work including, .unbind, .die, and .undelegate. I'm using jquery 1.6 so I can't use .off. What's the best way to accomplish this?
This is essentially the form my code takes. I call unbind first to remove the handler if it already exists.
OBJECT 1
{
myNameSpace.MY_CUSTOM_EVENT_STRING = "my_event";
$cachedFieldObject.trigger(myNameSpace.MY_CUSTOM_EVENT_STRING);
}
OBJECT 2
{
function myfunctionName(var1) {myObject.myObjectsFunction()}
$("#divID").find(".fieldClass").unbind(myNameSpace.MY_CUSTOM_EVENT_STRING, myfunctionName).live(myNameSpace.MY_CUSTOM_EVENT_STRING, myfunctionName);
}