Skip to content

Instantly share code, notes, and snippets.

@brianjmiller
Last active Jan 1, 2016
Embed
What would you like to do?
Base BB View
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;
}
}
);
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");
}
}
);
<label class="{{_className}}-endpoint">
Endpoint: <input type="text" class="{{_className}}-endpoint" value="{{endpoint}}" readonly>
</label>
<label class="{{_className}}-username">
Username: <input type="text" class="{{_className}}-username" value="{{username}}" readonly>
</label>
<label class="{{_className}}-password">
Password: <input type="password" class="{{_className}}-password" value="{{password}}" readonly>
</label>
<button class="{{_className}}-create">Create</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment