1

yui3 构造Y.on()可以用来为 yui2 小部件上的事件设置监听器,还是它们只是使用单独的事件系统?

4

1 回答 1

4

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
于 2010-09-14T17:17:40.063 回答