| Page 1 of 1 | [ 5 posts ] |
MarcYUI Contributor
|
Hi,
I am developing a YUI App that uses Handlebars with both dynamic and server side rendering support. My homepage is a list of items. When I first load the page, I want server side rendering to be used, because it's faster. On subsequent pagination etc, I want to use client side/json rendering. I'm just wondering how to set activeView when the content is rendered server side. I want to avoid reloading the content as a JSON call if it's already there. Cheers, Marc |
|
Marc,
This is a great question. I've been experimenting with some different approaches of solving this with the hope that we can provide a streamlined solution in YUI. The basic idea behind the approaches I've been taking is to serialize the data the server is using to render the page (the models and model lists) to JSON, and dump that data into a <script> element within the HTML document the server is creating. If you're Gzipping the HTML pages (which you should) the amount of extra KB-weight will be minimal as gzipping is good at handling duplicate strings. Then the JavaScript running in the browser can revive that state and take over from there. You can see this being done in Photos Near Me: Server serializes the data it's using to render the HTML: https://github.com/ericf/photosnear.me/ ... s#L130-147 Placeholders in the HTML for that data: https://github.com/ericf/photosnear.me/ ... ars#L33-53 Client-side JavaScript reviving state and taking control: https://github.com/ericf/photosnear.me/ ... rs#L55-102 I hope that helps guide you to something that will work for your app. Once this pattern becomes more fully baked and support widgets revivification through the same conduit, I hope to make it a feature of YUI. Also it's really great to see you taking this approach of utilizing both the server and client to make your app awesome |
MarcYUI Contributor
|
Hey Eric,
Thanks for that reply. That sounds like a workable solution although putting the hard-code data into the html seems a bit inelegant (but so is putting in handlebar templates). Wouldn't it be cool if we could reference content in script references by id? But I would think that access to some shortcut would be a better solution. Something that allows you to say in stead o .dispatch(). .dispatch({render:false}), so that rendering is bypassed but a certain view does become active and all associated events also. |
|
mschipperheyn wrote: Thanks for that reply. That sounds like a workable solution although putting the hard-code data into the html seems a bit inelegant (but so is putting in handlebar templates). Wouldn't it be cool if we could reference content in script references by id? I'm not sure I follow you, can you elaborate on what you mean and how you'd do it differently? mschipperheyn wrote: But I would think that access to some shortcut would be a better solution. Something that allows you to say in stead o .dispatch(). .dispatch({render:false}), so that rendering is bypassed but a certain view does become active and all associated events also. That's what this is doing, it's calling `showView()` and passing `render: false` as an option. Which tells the Y.App instance to not render the view (since it is already rendered by the server.) |
MarcYUI Contributor
|
Huh, ok. Then I should be good to go. I guess I misunderstood you. I'll have a another look. Struggling with accessing parent scope right now.
|
| Page 1 of 1 | [ 5 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