1. Home
  2. Docs
  3. Application Framework
  4. Javascript Framework
  5. Extensions

Extensions

Controller.override()
Model.override()

All controllers and models have a built in override() method which allow you to extend its internal methods with your own decorator methods.

Any methods you provide in your override will recieve the parent method as its first argument, followed by all of the normal parameters which are passed in the call. Even if you are adding a method to the model which does not exist in its base implementation, you will still receive a parent callback in your override.

@Example Code

(function($, undefined){ 
    var AcmeController = mwp.controller.model.get( 'acme-controller' );

    AcmeController.override({
        init: function( _parent ) {
            _parent.call( this );
            this.viewModel.extendedData = ko.observable('The more, The merrier.');
        }
    });
})(jQuery);
Was this article helpful to you? Yes No

How can we help?