This is very easy to do. What you need to do is to replace the default Backbone.Sync object with one that will pull prebuilt data. This is what I have been using so far. It just takes an existing table of mock data and when a request comes in uses the URI as a key to retrieve the data and resets the data for the collection.
Obviously this only works for reading data, for Update, Delete etc things get a little more complex but there is no reason to not be able to expand this approach.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backbone.sync = (method, collection, {url: url}) -> | |
collection.reset(My.Sync.data[url]) |
No comments:
Post a Comment