Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 3rd, 2012  |  syntax: None  |  size: 0.71 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $.subscribe = function( eventName, obj, method ){
  2.     $(window).bind( eventName, function() {
  3.         obj[method].apply( obj, Array.prototype.slice.call( arguments, 1));
  4.     });
  5.     return jQuery;
  6. }
  7.  
  8. $.unSubscribe = function( eventName, obj, method ){
  9.     $(window).unbind( eventName, function() {
  10.         obj[method].apply( obj, Array.prototype.slice.call( arguments, 1));
  11.     });
  12.     return jQuery;
  13. }
  14.  
  15. $.publish = function(eventName){
  16.     $(window).trigger(eventName, Array.prototype.slice.call( arguments, 1));
  17.     return jQuery;
  18. }
  19.  
  20. // called like this:
  21.  
  22. $.subscribe('locationReadyForTimer', this.mapLoadHandler, 'loadHandler');
  23. $.unSubscribe('locationReadyForTimer', this.mapLoadHandler, 'loadHandler');