DON’T REUSE VIEWS
new MyView({el: this.$(‘...’)})
Thursday, May 31, 12
Slide 27
Slide 27 text
DO REUSE DOM ELEMENTS
(SAFELY)
view.setElement(...)
Thursday, May 31, 12
Slide 28
Slide 28 text
DO BE CAREFUL WITH
INNERHTML
var p = document.createElement(‘p’)
p.innerHTML = ‘\o/’
var b = p.childNodes[0]
p.innerHTML = ‘’
console.log(b.innerHTML)
Thursday, May 31, 12
Slide 29
Slide 29 text
DON’T _.BINDALL
_.bindAll(this)
Thursday, May 31, 12
Slide 30
Slide 30 text
DO USE EVENT CONTEXTS
model.on(‘change’, this.change, this)
Thursday, May 31, 12
Slide 31
Slide 31 text
DO DESTROY VIEWS
Thursday, May 31, 12
Slide 32
Slide 32 text
DO DESTROY VIEWS
this.model.off(null, null, this)
Thursday, May 31, 12
Slide 33
Slide 33 text
DO DESTROY VIEWS
this.model.off(null, null, this)
this.collection.off(null, null, this)
Thursday, May 31, 12
Slide 34
Slide 34 text
DO WRAP ROUTER#ROUTE
Authorization
Clean Up Old Views
Thursday, May 31, 12
Slide 35
Slide 35 text
KEEP ROUTE HANDLERS
SIMPLE
Fetch Data
Create Views
Clean Up Old Views
Thursday, May 31, 12
Slide 36
Slide 36 text
DO WRAP BACKBONE.SYNC
Backbone.sync = function(...) { ... };
Thursday, May 31, 12