Last active
January 1, 2016 20:49
-
-
Save brianjmiller/8199475 to your computer and use it in GitHub Desktop.
Base BB View
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
return Backbone.View.extend( | |
{ | |
_nodes: null, | |
renderCfg: function () { | |
return this._renderCfg || {}; | |
}, | |
renderContext: function () { | |
console.log("views/base::renderContext"); | |
return { | |
_className: this.className | |
}; | |
}, | |
render: function () { | |
console.log("views/base::render"); | |
var context = this.renderContext(), | |
renderCfg = this.renderCfg(), | |
prop; | |
this.$el.html(this.template(context)); | |
this._nodes = {}; | |
if (renderCfg.nodes) { | |
for (prop in renderCfg.nodes) { | |
this._nodes[prop] = this.$(renderCfg.nodes[prop]); | |
} | |
} | |
return this; | |
} | |
} | |
); |
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 CLASS_NAME = "rs-app-checklist"; | |
return ViewBase.extend( | |
{ | |
template: templates["app/checklist.html"], | |
className: CLASS_NAME, | |
events: { | |
"click button.rs-app-checklist-create": "_handleCreate" | |
}, | |
renderContext: function () { | |
console.log("views/checklist::renderContext"); | |
var context = ViewBase.prototype.renderContext.call(this); | |
return _.extend(context, this.model.toJSON()); | |
}, | |
_renderCfg: { | |
nodes: { | |
endpoint: "input." + CLASS_NAME + "-endpoint", | |
username: "input." + CLASS_NAME + "-username", | |
password: "input." + CLASS_NAME + "-password" | |
} | |
}, | |
_handleCreate: function () { | |
console.log("views/checklist::_handleCreate"); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment