views:

17

answers:

1

Can the yui3 construct of Y.on() be used to setup listeners for events on yui2 widgets, or do they simply use separate event systems?

+2  A: 

They use separate event systems. However, you can use Y.on() to set up DOM listeners that trigger methods on YUI 2 Widgets.

Y.on('focus', Y.bind(myCalendar.show, myCalendar), '#birthdate');

or more generically

Y.on('click', function () {
    /* do other stuff... */

    myDataSource.sendRequest('filter=active', {
        success: myDataTable.onDataReturnInitializeTable,
        scope: myDataTable
    });

    /* ...and more stuff */
}, '#date-filter');

Y.on() can't be used to subscribe to widget custom events in YUI 2, though.

Y.on('activeTabChange', thisWontWork, myTabView); // does nothing
Luke