| Page 1 of 1 | [ 3 posts ] |
|
I'm unclear on best practices for handling model that has other models as an attribute. For example, if I have a model of a person
ATTRS: { name: {value: null}, age: {value: null}, city: {value: null}, state: {value: null}, } and I want to have a array or similar collection as one of the attributes. Something like books with its own ATTRS of title, author, publisher or vacations with ATTRS of location,date,rating. In the case I'm modeling now the sub models are only used in by the main model but I can see other scenarios where they are also used independently (students and teachers, players and teams etc) Would I create a ModelList and use it in the ATTRS section? Make custom getter/setters that handled an array? Handle it all with methods outside of the ATTRS manually? |
|
You need to break it down a bit further...I have 4 pieces.
+Book Model & VIew This will define the data structure of a book, title, author, genre. The view will be coupled to the model and determine how an individual book is rendered in the list. e.g <li> +Book Model-list This is pretty simple, but can support some helper filter methods e.g genre() +Lastly a Book Shelf View which will contain a book model list. This is the highest level view, it will instantiate your Book List which provides acess to this.bookList.add() If you want more flexibility, a book shelf would be a model and you could have a list of this which would be appropriot for a say, Library View? OR model and list of libraries.....you get the idea. Example http://jsfiddle.net/hendross/QDehF/11/ |
|
Thanks, that was very helpful
|
| Page 1 of 1 | [ 3 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