javascript - Should I use nested collections to organize my backbone.js app? -
i'm having bit of tough time wrapping head around backbone. want utilize deliver info based on different races in different cities.
so, ideally, have collection of cities, , each item in collection collection of races in city, composed of candidates (i think). on right path?
my info feed array of objects, various identifying key: values.
example: var info = [ { 'name': 'john smith', 'race': 'mayor', 'city': 'york' }, { 'name': 'jack black', 'race': 'mayor', 'city': 'york' }, { 'name': 'billy bob', 'race': 'mayor', 'city': 'trenton' } , { 'name': 'burt reynolds', 'race': 'mayor', 'city': 'trenton' } ]
backbone not back upwards nested models/collections well, , in utilize case, don't see why necessary.
one way of doing want accomplish create 1 collection of of data, utilize .where method info want when ready manipulate/display it. instance, create collection of of data, lets refer mycollection, if want deliver info based on mayor race in trenton, var trentonmayorrace = mycollection.where({race: 'mayor', city: 'trenton'}) , homecoming array of models match attributes.
javascript backbone.js
No comments:
Post a Comment