| Page 1 of 2 | [ 11 posts ] | Go to page 1, 2 Next |
|
I have a number of views in the app which may not actually render when the app changes the active view to them because their model data is not yet loaded. I was using the app to default a loading spinner on the navigate event, and then listening for a '*:rendered' event that would be bubbled from the views, to turn of the loading image.
unfortunately when I fire an event in my view's render method it does not bubble to the App, I am guessing because its not finished the render phase it's not yet a bubble target. what is the best way to approach this? just to clarify the view's render method will do nothing if model data is not loaded and not fire the event, but the initializer sets up a call to render after the model data is loaded, on this occassion the render method will 'actually' render and fire the "rendered" event. Thanks Richard. |
|
added js fiddle to confirm behaviour. Not sure if this would warrant a feature request, or could someone suggest a better way for me to code the problem.
Thanks. http://jsfiddle.net/bvxh6/ |
|
Hi Richard, your correct it isn't yet a bubble target.
If you want something to happen after the view is ready you can put it in the callback of showView() http://yuilibrary.com/yui/docs/api/clas ... d_showView I made a module to help with firing a loading sequence with Y.App which you may find useful http://yuilibrary.com/gallery/show/app-loading Unfortunately I haven't put it on the CDN because I haven't had a chance to make any demo's, documentation or do proper testing on it but we are using it on 2 live apps without issue. Jeff |
|
ok, so I dont want my views render method to be blocking, so it will always return to the app, but somehow I want to signal to the app if the render happened or not.
So coming back to your suggestion can the callback receive an event object or something from the view that could pass the rendered state or if I use your extension, can the view fire the 'loadingComplete' event and if it is not fired, will the app stay in the 'loading' state? Thanks, |
|
I updated your fiddle to use the callback http://jsfiddle.net/bvxh6/2/ (open your console to see the logs)
|
|
im not sure this helps, this will always fire 'rendered' once the render method finishes and execution returns to the app. I only want it to fire 'rendered' if some logic/test within the view is true (i.e. some model io has completed and the render was able to render) otherwise I want render to return to the app silently ('pseudo' silently). The view, handles the re-calling of the render method if the model io completes later, and again on this occasion i need to listen and act on the event in app. I think your gallery module was closer to addressing this, but I did try to YUI().use(...) it but it failed. Do I need to host the code myself?
|
|
actually, looking at this, the callback as the view instance, so I could set an attribute in the view to pass rendered state and introspect this in the callback. After that the app is a bubble target to any delayed rendering anyway so I can use on("*:rendered". So all in all I think this can be covered off now!?
Is there any logic/reason as to how and when the app establishes itself as a bubble target? This would be much neater if I could fire the rendered event from the render method. Thanks for your help Richard. |
|
Sounds like you found a solution that works
Yes you will have to self host that module. The code is not on the CDN and I won't be putting it up there until I have a chance to test and document it. If you follow this link https://github.com/hatched/yui3-gallery ... ing.js#L22 you will see the method at which the app is set as a bubble target for the view. App Base _attachView() http://yuilibrary.com/yui/docs/api/clas ... attachView There is some talk about different ways to accomplish this from within Y.App so feel free to create a ticket or pop into #yui on irc.freenode.net and discuss. Hope this answers all your questions! |
|
The timing of when the view's events will start bubbling to the app is something that I want to address. I've been hearing feedback like this that points me to the direction that the `view.addTarget(app)` call should happen sooner, and before the view's `render()` method is called.
There's one change going into 3.5.1 that allows you to affect whether a view will be rendered (or re-rendered in the case of a preserved view) or not: `app.showView('foo', null, {render: false})`. You can see more details about this change here: https://github.com/yui/yui3/commit/3385 ... de6ff3b65a There are some high level ideas of where I want to take Y.App's view management captured in TODOs: https://github.com/yui/yui3/blob/master ... ase.js#L18 Those are all things I'm thinking about and plan to flush out for 3.6.0 to make the view management more robust and possibly reusable as a class extension for mixing into Y.View subclasses as well. |
|
I would have when the showView method was called then the app should become a bubble target for that view. At least this would seem to make sense for synthetic events, not sure if there are considerations for the DOM events especially when using transitions?
|
| Page 1 of 2 | [ 11 posts ] | Go to page 1, 2 Next |
| 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