You've got a lot of Gal

Yet another blog about Ruby, Rails, Javascript, Apple, Malteses and Shih-Tzus by Gal Steinitz

This site is completely static. It was last generated with Octopress and Jekyll on Sep 02, 2013 and hosted on github pages.

Fire and Consume Custom Global Events in jQuery

To bind something to a custom event:

1
2
3
$().bind("sneeze",function(){
  console.log("bless you!");
});

and to fire that event, from anywhere else?

1
$.event.trigger("sneeze");

result in the console, is as expected:

1
bless you