Search code examples
javascriptjqueryyui3

in YUI3 is it possible to attach a single handler to multiple events?


so is something like this possible?

Y.one("input.units").on("keyup change", function(e){
    ...
});

the jquery equivalent is

$("input.units").bind("keyup change", function(e){
    ...
});

Solution

  • Yes, this is possible. Just pass an array of event names instead of a string:

    Y.one('input.units').on(['keyup', 'change'], function (e) {
        // ...
    });