1

How would I extend an extended view parent method not to override, keep parents method statements and add some custom code, here is the example case

var SomeView = View.extend({
  parentMethod: function() {
    //some parent code
  }
})


var MyView = SomeView.extend({
  parentMethod: function() {
     //keep parents statements and extend
  }
})
fefe
  • 8,755
  • 27
  • 104
  • 180
  • Possible duplicate of [Accessing parent class in Backbone](https://stackoverflow.com/questions/8970606/accessing-parent-class-in-backbone) – Emile Bergeron Apr 05 '18 at 23:54

1 Answers1

1

JavaScript does not provide a simple way to call super — the function of the same name defined higher on the prototype chain. If you override a core function like set, or save, and you want to invoke the parent object's implementation, you'll have to explicitly call it

http://backbonejs.org/#Model-extend

   var MyView = SomeView.extend({
      parentMethod: function() {
         SomeView.prototype.parentMethod.apply(this, arguments);
         //some additional logic
      }
    })
yvoytovych
  • 871
  • 4
  • 12