happen makes real events happen in browser


JavaScript is great at listening for handling events - a user clicks, drags, or types, and we know: jQuery makes it easy to say $('#foo').click(function() {}).

But what about the opposite - creating events? That's where happen comes in it makes it simple to interact with the createEvent API, which yields real events.

Why? Script interfaces for web scraping, test applications based on really whether they respond to events, emulate touch or mouse events as vice versa, and more.

Doesn't jQuery Do This?

Not really. jQuery can trigger events that it binds, through its .trigger('eventname') function, but can't trigger events bound outside of jQuery's kingdom. Happen can trigger events bound the old fashioned way with .onclick, the new-fashioned way with .addEventListener, and even just bound by your browser with a default behavior.

var say_hi = document.getElementById('say-hi'),
    click_other = document.getElementById('click-other');

say_hi.onclick = function() {
    alert('hi');
};

click_other.onclick = function() {
    happen.click(say_hi);
    return false;
}

Browserify

npm install happen

GitHub

git clone https://github.com/tmcw/happen.git