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
// Forked/modified from: https://gist.github.com/maxbrunsfeld/1542120 | |
// This method gives you an easier way of calling super when you're using Backbone in plain javascript. | |
// It lets you avoid writing the constructor's name multiple times. | |
// You still have to specify the name of the method. | |
// | |
// So, instead of having to write: | |
// | |
// var Animal = Backbone.Model.extend({ | |
// word: "", | |
// say: 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
// Adds an `append` option to the Backbone Router | |
Backbone.Router.prototype.navigate = (function(origNavigate) { | |
return function(fragment, options) { | |
if (options && options.append) { | |
fragment = Backbone.history.fragment + fragment; | |
delete options.append; | |
} | |
return origNavigate.call(this, fragment, options); | |
}; | |
})(Backbone.Router.prototype.navigate); |
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
// I wrote this when Backbone was like v0.2 - now there are many many tools like Marionette, | |
// and even things native to Backbone (like `stopListening`) that invalidate a lot of this | |
var SubView = Backbone.View.extend({ | |
// tagName: must be implemented | |
// className: must be implemented | |
// template: must be implemented | |
initialize: function() { | |
this.model.on("change", this.render, this); | |
this.model.on("close", this.close, this); |
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
(function(root, factory) { | |
if (typeof define === "function" && define.amd) { | |
define(["underscore", "backbone", "backboneBabySitter"], function(_, Backbone, ChildViewContainer) { | |
return factory(_, Backbone, ChildViewContainer); | |
}); | |
} | |
else if (typeof exports !== "undefined") { | |
var _ = require("underscore"); | |
var Backbone = require("backbone"); | |
var ChildViewContainer = require("backboneBabySitter"); |
NewerOlder