Subscribe to events.
ractive.on( eventName, handler ) Returns an
Objectwith acancelmethod, which removes the handler.eventName StringThe name of the event to subscribe to
handler FunctionThe function that will be called, with
ractiveasthis. The arguments depend on the event. Returningfalsefrom the handler will stop propagation and prevent default of DOM events and cancel event bubbling.ractive.on( obj ) Returns an
Objectwith acancelmethod, which removes all handlers in the passed-inobj.obj ObjectAn object with keys named for each event to subscribe to. The value at each key is the handler function for that event.
Examples
Examples
// single handler to function
ractive.on( 'activate', function () {...});
// wildcard pattern matching
ractive.on( 'foo.*', function () {...} );
// multiple handlers to one function
ractive.on( 'activate select', function () {...} );
// map of handler/function pairs
ractive.on({
activate: function () {...},
select: function () {...}
});
// knock yourself out:
ractive.on({
activate: function () {...},
'bip bop boop': function () {...},
'select foo.* bar': function () {...}
});