2014년 12월 11일 목요일

[backbonejs] Usage of Collection in Backbonejs

What is the necessity of Collection of Backbonejs ?? What will happen if I avoid Collection and only use View and Model ?? What are the responsibilities of Collection ??



Collections are arrays of Model of the same type (quoting official documentation, "Collections are ordered sets of models."). 
They usually store domain/business logic that touches several models (or all of them) at once (e.g. filtering -- to filter models you should organize them somehow). They also provide bulk fetching.
Collections not always necessary, but sometimes they are irreplaceable.



Thank you  Konstantin Kitmanov for your reply. Actually I am beginner in Backbone.js. That's why some issues are little ambiguous to me. I am trying to learn more and more about backbone.js through Google. I am trying to develop a small application. In this regard I am looking for a mentor.
Could you please help me  in my another problem which I mailed in this group ?? Subject of that mail is "backbone.js and SLIM framework PUT request (Important)" .


Encountering some error first thing you should do is to google it's text and try to correlate it to your code. As a web-developer you should keep you browser's console open and see any error immediately. 
If that doesn't help, you can post it online, but you should narrow your code to as few lines of code as possible ('minimal broken code'), and always include error's text. Narrowing your code sometimes allows you to see and fix the problem. It also helps to determine the area of the problem and post a question to a proper forum (no one likes to see question about PHP in JS group, and so on).

There's also good guides on how to ask for help, e.g. this one (applies not only for StackOverflow).  



Thanks  Konstantin Kitmanov. I'll try to follow your advice. But I stuck with that problem.  I am trying my best to come out of that problem.



I also recommend this guide: whathaveyoutried.com



*Collection* of models - says it all.


댓글 없음:

댓글 쓰기