Skip to content

Instantly share code, notes, and snippets.

@nsfmc
Created April 26, 2013 20:53
Show Gist options
  • Save nsfmc/5470365 to your computer and use it in GitHub Desktop.
Save nsfmc/5470365 to your computer and use it in GitHub Desktop.
an autocomplete snippet which fills out all the backbone boilerplate needed when adding new backbone models to an extant KA project.
<snippet>
<content><![CDATA[
/**
* a backbone model for ${1:Model}
*/
window.${1:Model} = Backbone.Model.extend({
defaults: {
},
initialize: function(options) {
Backbone.Model.prototype.initialize.call(this, options);
// initialize model here
},
});
/**
* This is the backbone view for the ${1:Model}
*/
window.${1:Model}View = Backbone.View.extend({
model: ${1:Model},
_template: Templates.get("${2:template-folder}.${3:template-file-no-extension}"),
events: {
},
initialize: function(options){
Backbone.View.prototype.initialize.call(this, options);
// set up the view here
},
render: function(){
// draw here
}
});
\$(function(){
var ${4:demoModel} = new ${1:Model}();
var ${5:demoView} = new ${1:Model}View({
model: ${4:demoModel},
el: '${6:.jQuerySelector}'
});
${5:demoView}.render();
})
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>backbone</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment