We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monkey = HAL.Model.extend({}); Monkeys = HAL.Collection.extend({ model: Monkey }); monkeys_list = [ { "_links": { "self": { "href": "/zoo/monkeys/1" } }, "id": "1", "name": "Petunia", "traits": [ "throws poo", "hosts tea parties" ], "_embeded": { "events": [ { "_links": { "self": { "href": "/zoo/events/343" } }, "date": "2012-09-11", "description": "Threw a tea party for the Queen. After sharing some particularly lovely shortbread biscuits, started throwing poo." }, { "_links": { "self": { "href": "/zoo/events/301" } }, "date": "2011-12-19", "description": "Gave a lovely teapot to a child for Chistmas" } ] } }, { "_links": { "self": { "href": "/zoo/monkeys/3" } }, "id": "3", "name": "Lancelot", "traits": [ "aspires to be a space monkey", "dabbles in astronomy and astrophysics" ], "_embeded": { "events": [ { "_links": { "self": { "href": "/zoo/events/444" } }, "date": "2013-03-28", "description": "Acted as copilot on the Soyuz TMA-08M mission to the ISS." }, { "_links": { "self": { "href": "/zoo/events/45" } }, "date": "2009-07-02", "description": "Repremanded after firing a prototype rocket into the nearby Gazelle aviary." } ] } } ]; > monkeys = new Monkeys(monkey_list) child {links: Object, embedded: Object, attributes: Array[2], length: 0, models: Array[0]…} > monkeys.models [] > monkeys.length 0
If the Monkey model and collection were standard Backbone objects (instead of HAL objects), you'd get the following:
> monkeys.models [ child, child ] > monkeys.length 2
Resetting the collection with the JSON array works as expected:
> monkeys = new Monkeys() > monkeys.reset(monkeys_list) child {links: Object, embedded: Object, attributes: Array[2], length: 2, models: Array[2]…} > monkeys.models [ child, child] > monkeys.length 2
The text was updated successfully, but these errors were encountered:
1d52f19
Merge pull request #10 from chadkouse/collection_fix
f889d6f
fixes #8
No branches or pull requests
If the Monkey model and collection were standard Backbone objects (instead of HAL objects), you'd get the following:
Resetting the collection with the JSON array works as expected:
The text was updated successfully, but these errors were encountered: