This file contains hidden or 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 hidden or 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 hidden or 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
| Backbone.Notifications = {}; | |
| _.extend(Backbone.Notifications, Backbone.Events); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Handlebars.getTemplate = function(name) { | |
| if (Handlebars.templates === undefined || Handlebars.templates[name] === undefined) { | |
| $.ajax({ | |
| url : 'templatesfolder/' + name + '.handlebars', | |
| success : function(data) { | |
| if (Handlebars.templates === undefined) { | |
| Handlebars.templates = {}; | |
| } | |
| Handlebars.templates[name] = Handlebars.compile(data); | |
| }, |
This file contains hidden or 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 hidden or 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