Re:Backbone patterns
by radagaisus on Saturday December 24, 2011 @07:04PM
(#3390058)
This is all fairly basic patterns. More interesting patterns are using collections inside a model, using sparse arrays or transparent loading (for infinite scroll), creating a "loading" event and handling loading, optimizing number of render calls, complicated routes, and using a vent to pass events and information between views. Those are the 'tougher' challenges I deal with on my backbone apps.
Re:Backbone patterns
by zenocon on Saturday December 24, 2011 @10:28PM
(#3390357)
I tend to agree. I don't want to discount the nice work that the author put forth, but I grabbed a cheap, well-written ebook here: http://recipeswithbackbone.com/ that has many more of the patterns you mention. It was worth whatever I paid for it.
Re:Backbone patterns
by mryan on Sunday December 25, 2011 @08:11AM
(#3390970)
Why not fork the project, add some of these topics, and send a pull request?
I'm not being snarky or sarcastic - I personally would love to see some of the more advanced topics you mention included in the list of patterns, in particular loading events and optimisation. Unfortunately I don't think I know enough about Backbone to contribute anything useful - the only non-standard thing I have done so far is basic integration with Celery (https://github.com/mikery/django-celery-backbone).
Re:Backbone patterns
by joelhooks on Saturday December 24, 2011 @07:29PM
(#3390084)
I'd be really interested in reading about these areas as well. It's been cool seeing the emergent knowledge share around Backbone patterns and practices.
Re:Backbone patterns
by ben1040 on Sunday December 25, 2011 @01:57AM
(#3390609)
collections inside a model
I would really love to know the best practice for this, because I was trying to work with something that basically amounted to a model with two or three collections as well as a few simple properties.
But, when I went searching a month or two ago I couldn't really find much in the way of how to handle this sort of nested collection. Is there a good example out there?
ViewSubModel listens model and collection ( using model.bind() and collection.bind() ). If someting happened, which should inform all submodels i fire an event with a collection.trigger(). Say if i want to hide MainModel, MainModel's View calls model.subModelCollection.trigger('hideParent') before remoing it's "el".
* : i'm sorry if you confused because of my explanation. i tried my best.
I'm not being snarky or sarcastic - I personally would love to see some of the more advanced topics you mention included in the list of patterns, in particular loading events and optimisation. Unfortunately I don't think I know enough about Backbone to contribute anything useful - the only non-standard thing I have done so far is basic integration with Celery (https://github.com/mikery/django-celery-backbone).
I would really love to know the best practice for this, because I was trying to work with something that basically amounted to a model with two or three collections as well as a few simple properties.
But, when I went searching a month or two ago I couldn't really find much in the way of how to handle this sort of nested collection. Is there a good example out there?
SubModel,CollectionSubModel
MainModel { subModelCollection : CollectionSubModel }
ViewSubModel { model: SubModel, collection: MainModel.subModelCollection }
ViewSubModel listens model and collection ( using model.bind() and collection.bind() ). If someting happened, which should inform all submodels i fire an event with a collection.trigger(). Say if i want to hide MainModel, MainModel's View calls model.subModelCollection.trigger('hideParent') before remoing it's "el".
* : i'm sorry if you confused because of my explanation. i tried my best.