This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ok: | |
this.stateModel.on('change:readMore', this.renderReadMore, this); | |
// Awesome: | |
this.listenTo(this.stateModel, 'change:readMore', this.renderReadMore); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var model = new Backbone.Model({counter: 1}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)rulesAreForDouches { | |
if (!goodStuff) { | |
return; | |
} | |
if (badStuff) { | |
return; | |
} | |
[self doGood]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FirstView = Backbone.View.extend({ | |
initialize: function() { | |
Backbone.Notifications.on('SomeViewRendered', function (msg) { | |
alert(msg); | |
}, this); | |
} | |
}); | |
var SecondView = Backbone.View.extend({ | |
render: function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ((viewA.origin.y < viewB.origin.y) && (viewB.origin.y + viewB.size.height < viewA.origin.y + viewA.size.height)) { | |
[self doSomething]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL viewAcontainsViewB = (viewA.origin.y < viewB.origin.y) && (viewB.origin.y + viewB.size.height < viewA.origin.y + viewA.size.height); | |
if (viewAcontainsViewB) { | |
[self doSomething]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compiledTemplate = Handlebars.templates['hello']; | |
var html = compiledTemplate({ name : 'World' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compiledTemplate = Handlebars.getTemplate('hello'); | |
var html = compiledTemplate({ name : 'World' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rawTemplate = '<p>Hello {{name}}</p>'; // (step 1) | |
var compiledTemplate = Handlebars.compile(rawTemplate); // (step 2) | |
var html = compiledTemplate({ name : 'World' }); // (step 3) | |
// html content will now be: <p>Hello World</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initialize: function() { | |
// Observe changes to the model and call the render function when they happen | |
this.model.on('change', this.render, this); | |
// Render the view for the first time | |
render(); | |
} | |
userMarkedObjectAsFavorite: function() { | |
// We're changing the mode, not the UI |
OlderNewer