
Untitled
By: a guest on
May 3rd, 2012 | syntax:
None | size: 0.71 KB | hits: 15 | expires: Never
$.subscribe = function( eventName, obj, method ){
$(window).bind( eventName, function() {
obj[method].apply( obj, Array.prototype.slice.call( arguments, 1));
});
return jQuery;
}
$.unSubscribe = function( eventName, obj, method ){
$(window).unbind( eventName, function() {
obj[method].apply( obj, Array.prototype.slice.call( arguments, 1));
});
return jQuery;
}
$.publish = function(eventName){
$(window).trigger(eventName, Array.prototype.slice.call( arguments, 1));
return jQuery;
}
// called like this:
$.subscribe('locationReadyForTimer', this.mapLoadHandler, 'loadHandler');
$.unSubscribe('locationReadyForTimer', this.mapLoadHandler, 'loadHandler');