如何在YUI中将事件挂钩到数据源?

时间:2022-06-19 23:56:40

http://developer.yahoo.com/yui/datasource/#events

http://developer.yahoo.com/yui/datasource/#events

I'm trying to use the responseParseEvent but I don't know how to hook into into my datasource object because YUI doesn't provide any examples.

我正在尝试使用responseParseEvent,但我不知道如何挂钩到我的数据源对象,因为YUI没有提供任何示例。

Sidenote: Has anybody else noticed this with YUI? That their documentation doesn't contain nearly as many examples as jQuery?

旁注:有没有人注意到YUI?他们的文档不包含与jQuery几乎一样多的示例?

1 个解决方案

#1


5  

instance.subscribe(eventName, callback) is a standard signature for most events across components in YUI 2.

instance.subscribe(eventName,callback)是YUI 2中跨组件的大多数事件的标准签名。

myDataSource.subscribe('responseParseEvent', function (e) {
    /*
     * available properties:
     *   e.request
     *   e.response
     *   e.callback
     *   e.caller
     */
});

YUI 3 follows a similar convention, but uses the methods on() and after()

YUI 3遵循类似的约定,但使用on()和after()之后的方法

myYUI3DataSource.on('data', function (e) { ... });

#1


5  

instance.subscribe(eventName, callback) is a standard signature for most events across components in YUI 2.

instance.subscribe(eventName,callback)是YUI 2中跨组件的大多数事件的标准签名。

myDataSource.subscribe('responseParseEvent', function (e) {
    /*
     * available properties:
     *   e.request
     *   e.response
     *   e.callback
     *   e.caller
     */
});

YUI 3 follows a similar convention, but uses the methods on() and after()

YUI 3遵循类似的约定,但使用on()和after()之后的方法

myYUI3DataSource.on('data', function (e) { ... });