Search code examples
ractivejs

ractive : how to call super () inside a child class?


That is going to be a super easy question. I have the following code :

var component = ractive.extend ({
...
onrender : function (){...}
...
})

var view = component.extend({
...
onrender : function (){...}
})

The onrender in view is executed and shadows the onrender in component. Is there a way to call the onrender in component from the view context?


Solution

  • You can use this._super inside the overriding method to refer to the underlying function:

    onrender: function(){
        this._super();
        // ...
    }
    

    It's on this page in the docs (though example is with the old lifecycle methods).