js equivalent of jQuery's bind?
If I trigger a custom event using jQuery:
- $('#dog').trigger('bulldog', ['fierce']);
and listen for it, using jQuery:
- $('#dog').bind('bulldog', handler);
- function hander(e, id) {
- alert(e.type + ": " + id);
- }
all is sweet.
If I listen for it without jQuery:
- document.getElementById('dog').addEventListener('bulldog', handler(), false);
the event is heard ok, but I get an exception saying the arguments couldn't be converted.
Searching a while for how to use custom events in javascript, it seems like custom class extensions are always used. Does this have to be the case, or I have I just got the syntax wrong above?