Skip to content

Instantly share code, notes, and snippets.

@dsugden
Created April 10, 2012 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsugden/2355351 to your computer and use it in GitHub Desktop.
Save dsugden/2355351 to your computer and use it in GitHub Desktop.
Example backbone view using the require.js API for dependencies
define([
'jquery',
'underscore',
'backbone',
'text!templates/athelete/atheleteForm.html'
'i18n!nls/atheleteLabel'
], function($, _, Backbone, atheleteForm, atheleteLabel ){
var AtheleteForm = Backbone.View.extend({
el: "#athleteForm",
initialize: function(){
this.render();
},
events: {
"submit form": "save",
"click #cancel": "cancel"
},
cancel: function() {
},
save: function() {
// backbone sync to Play!
},
render: function() {
this.model.set({atheleteLabel:atheleteLabel},{silent: true});
var compiledTemplate = _.template(atheleteForm, this.model.toJSON());
$(this.el).html(compiledTemplate);
return this;
}
});
return AtheleteForm;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment