Backbone.js Collection
mrbool.com
mrbool.com
var imageModel = Backbone.Model.extend...
Should be var ImageModel = Backbone.Model.extend...
Another thing, adding to the collection using add is not the best practice IMHO, imageGallery.add(images);
As far as I know it will trigger the add event for each model being added, I prefer adding multiple models via the reset methodDon't want to criticize the OP or something (I've read mostly great posts from mrbool...) but if anyone new to Backbone intending to learn from it, I suggest to take it with a grain of salt (and as other's stated, it's not using the latest backbone version - 1.0)
There are many great free resources for learning Backbone.js (backbonejs.org is one of the best, but not always easy to get started from there)
But I found that spending a few dollars on paid courses is sometimes worth it. I'm not affiliated, but for me there were 3 that I found well worth their cost for learning backbone quickly (using relatively "latest" best practices, as much as latest is a moving target)
1) code school's (part 1 and part 2) - simple but practical
2) tuts plus (also 2 parts, both are great), 2nd part has some free videos on nested collections, must watch
3) peep code (3 parts) - the only that I haven't used personally, but it got great reviews
I think backbone is here to stay, Angular / Ember might be nice for a new project, but if you want to refactor without rewriting your code from scratch the Angular or the Ember way, backbone is simply great for the job.
and about adding multiple things to collection the reason for using 'add' instead of 'reset' is, 'add' will maintain the existing data, while reset will clear the existing data then replace it.
I like the code schools's part 1 and 2 which was written by Jeremy Ashkenas, it is simple but practical, I agree.
> Classes often start in uppercase letters, while instances start with lowercase letters.
Listing 7: Get model from collection by client id
ImageGallery.getByCid(534);
The `getByCid` method has been removed since 0.9.10: https://github.com/documentcloud/backbone/compare/0.9.9...0....