javascript - How to extend the class which inherits Backbone.Events? -


i'm trying create following structure of classes using backbone.js inheritance model:

backbone.events -> parent -> child

child should call initialize parent, unfortunately not work. parent methods , properties not visible. please help.

my code

var parent = function() {     this.initialize.apply(this, arguments); };  _.extend(parent.prototype, backbone.events, {      initialize: function() {         // parent init     }, });  var child = function() {     this.initialize.apply(this, arguments); };  _.extend(child.prototype, parent, {     /* inherits parent */      initialize: function() {         // need call `parent init` code         // need init myself (child)         // not work         // parent methods , properties not visible         parent.prototype.initialize.call(this, arguments);     } }); 

just use following approach:

function parent() {     this.initialize.apply(this, arguments); };  _.extend(parent.prototype, backbone.events, {      initialize: function() {         // parent init     }, });  // pick extend method backbone parent.extend = backbone.model.extend;  var child = parent.extend({     initialize: function() {         // parent methods , properties visible         parent.prototype.initialize.apply(this, arguments);     } }); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -