| Page 1 of 1 | [ 4 posts ] |
|
Hi,
After I load data from Local Storage, I need to re-bind my ModelLists otherwise they're added as arrays. See code below. Code: loadGame: function() { var game = this.get('game'); game.load(function(req, res){ var squareData = JSON.parse(res).squareList; var squareList = new Y.SquareList(); for (key in squareData) { var square = squareData[key]; squareList.add(new Y.Square({ id: square.id, background: square.background, backgroundHover: square.backgroundHover })); } game.set('squareList', squareList); }); }, Is this the expected behavior? If not, what method should I use to make sure the returned data is bound as the correct type? Thanks, Matt |
|
This can happen more automatically by utilizing an attribute `getter` and `setter`, and Model's default `parse()` method which will parse a JSON response.
For ExampleClick here to see the revision history on this Gist. |
|
I'm trying to implement this idea in my own code. Should this be able to automatically connect a json array node called "squareList" into a model list?
My current code uses the ModelSync.REST mixin and the first level values are connecting up fine. |
|
Yeah it should, that's the idea. Are you seeing something not working?
|
| Page 1 of 1 | [ 4 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