3 ms·
There are ways around that. One of the easy ways is to simply in-line your JSON model when you generate the initial page. So essentially your webpage contains
by brunoc 15y ago
There are ways around that.
One of the easy ways is to simply in-line your JSON model when you generate the initial page.
So essentially your webpage contains the html structure you need, followed by something like
<script>
Myapp.start( { tasks: [ { id: 1, title: 'do something' } ])
</script>
So essentially you bootstrap your application in order to avoid a large AJAX call right off the bat.
- prateekdayal 15y agoIn fact Backbone's documentation on fetch (the method for populating collections using an AJAX call) specifically recommends this pattern - http://documentcloud.github.com/backbone/#Collection-fetch http://documentcloud.github.com/backbone/#Collection-fetch
- radicalbyte 15y agoI did almost exactly that on my last project. Works a treat. With html5 features (i.e. local storage) you can just cache data client-side and sync in the background. I.e. build a disconnected client-server application.