Jquery custom event implementation publishes a simple instance of an and subscription

  • 2021-06-28 10:19:09
  • OfStack

Simple instance of publish/subscribe implementation for Jquery custom events


// User Click logoff When button, broadcast 1 Custom events for any interested observer who needs to save state and navigate to logoff page 

$('#logoff').click(function(){
   $.event.trigger("logoff");// Radio broadcast 1 Events 
   window.location = "logoff.php";// Navigate to a new page 
});

Related articles: