Skip to content

Instantly share code, notes, and snippets.

@kimjoar
Last active December 16, 2015 22:30
Show Gist options
  • Save kimjoar/5507841 to your computer and use it in GitHub Desktop.
Save kimjoar/5507841 to your computer and use it in GitHub Desktop.
define(function(require) {
var View = require('base/view');
var menuTemplate = require('hgn!./menu');
var MenuView = View.extend({
template: menuTemplate,
initialize: function(options) {
this.cart = options.cart;
this.listenTo(this.cart, 'change', this.render);
},
render: function() {
this.renderTemplate(this.cart.toJSON());
return this;
}
});
return MenuView;
});
define(function(require) {
var Backbone = require('backbone');
var _ = require('underscore');
var View = Backbone.View.extend({
renderTemplate: function() {
var data = _.extend.apply(null, arguments);
var html = this.template(data);
this.$el.html(html);
return this;
}
});
return View;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment