Slack Note : May 21st 2019
Example code for overriding a function in an existing view. Need to drop the code into the main js file for the extension.
define('ExternalImages', ['Item.Model'], function (ItemModel) {
'use strict';
return {
mountToApp: function (application){
ItemModel.prototype.getImages = _.wrap(ItemModel.prototype.getImages, function(fn){
console.log("foo");
}
};
});
If we want to “extend” the class, we can call the original version with `fn.apply(this, _.toArray(arguments).slice(1));`
(like if the original version of the function has output you want to modify, like getContext).