Im just starting with Backbone.js. Ive subclassed Backbone.Model and Backbone.View :
var Message = Backbone.Model.extend(); var MessageView = Backbone.View.extend({ tagName: 'div', className: 'message', template: _.template('{{ html }}'), render: function(){ this.template({ html: this.model.html }); this.el.className.append(' ' + this.model.type); return this; } });
Then I tried to create an instance of each of them:
var message = new Message({html: html, type: type}); var messageView = new MessageView({model: message});
The last line leads to an error (in Chrome 12): Uncaught TypeError: undefined is not a function . It returns this error back to the f.extend.make function in Backbone.js.
The Backbone.js documentation on view.make says:
Convenience function for creating a DOM element of this type (tagName) with additional attributes and HTML content. Used internally to create the initial view.el
- Is jQuery or Zepto required?
- Can I remove this dependency by overriding
view.make in my call to Backbone.View.extend ?
source share