| Page 1 of 1 | [ 8 posts ] |
|
I have a plugin that uses an async-queue. I've added the plugin as an eventTarget for the async-queue but the events never bubble up to the plugin.
http://jsfiddle.net/bigwebguy/EUzPz/6/ you can see the plugin is a target of the queue, and the events are firing from the queue. they just never bubble up to the plugin. Thanks, Lee |
Alberto SantiniYUI Contributor
|
Hello Lee.
Maybe b.queue.q.on(...) and so on. Hope that helps, Alberto |
|
Yeah Alberto, there are a couple ways around it, such as re-firing the event from my plugin; but I'd like to know if there is something i'm doing incorrect or if there is a bug or some other reason its not working.
cheers. |
|
The events in AsyncQueue are not configured to bubble. You can have your plugin republish the events from the AQ passing bubbles:true like so:
Code: var queue = new Y.AsyncQueue(); queue.publish({ 'execute' : { bubbles: true }, 'shift' : { bubbles: true }, 'add' : { bubbles: true }, 'promote' : { bubbles: true }, 'remove' : { bubbles: true } }); queue.addTarget(this); this._queue = queue; HTH |
|
Luke, I noticed that already with the complete event (its not published at all for some reason) and you can see in my jsfiddle, i am publishing complete without success
Code: // async-queue for some reason doesnt publish the complete // event so it wont bubble regardless, however publishing // doesnt seem to make a difference q.publish('complete', { bubbles: true, emitFacade: true }); according to the eventTarget publish docs, bubble defauts to true as long as emitFacade is true: Quote: 'bubbles': whether or not this event bubbles (true) Events can only bubble if emitFacade is true. async queue publishes its events as: Code: this.publish({ 'execute' : { defaultFn : this._defExecFn, emitFacade: true }, 'shift' : { defaultFn : this._defShiftFn, emitFacade: true }, 'add' : { defaultFn : this._defAddFn, emitFacade: true }, 'promote' : { defaultFn : this._defPromoteFn, emitFacade: true }, 'remove' : { defaultFn : this._defRemoveFn, emitFacade: true } }); so unless the docs are incorrect, shouldn't those bubble already? |
|
it appears to be plugin related (or something that plugin uses) as it works fine when assigning a node instance as an eventTarget of async-queue
http://jsfiddle.net/bigwebguy/2sKZn/ i'll bug it. |
|
Have you added a bug for this? I dug around and found the issue. AsyncQueue's construction chains to EventTarget's constructor for extension, but it does not pass a 'prefix' config to the EventTarget constructor. Bubbled events are only accessible via prefixed event names.
You can patch it with this: Code: Y.AsyncQueue.prototype._init = function () { Y.EventTarget.call(this, { prefix: 'queue', emitFacade: true }); this._q = []; this.defaults = {}; this._initEvents(); }; Note the prefix config 'queue' passed as to EventTarget. Run that code before you instantiate any AsyncQueues, then to subscribe to the AsyncQueue's events from your plugin, use the prefixed event name, like so: Code: node.queue.on('queue:execute', callback); The node.queue is because your fiddle plugin's NS is also 'queue', though the two are entirely unrelated. This is absolutely a bug. If you filed it for a component other than AsyncQueue, please update it to be for AsyncQueue. I'll get the patch in the source and create a gallery module that patches it for use with 3.3.0. Thanks for finding this! |
|
yeah, the bug is here: http://yuilibrary.com/projects/yui3/ticket/2529864
I filed it against plugin because when i added node as a target of async-queue (no plugins), the events fired...so it seemed to be plugin specific. Maybe something else weird is going on there. node as eventTarget of async-queue (events bubble) http://jsfiddle.net/2sKZn/2/ thanks for looking at this. Lee |
| Page 1 of 1 | [ 8 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group