Anyone know how to extend modules using Kilimanjar...
# suitecommerce
c
Anyone know how to extend modules using Kilimanjaro? I started by using this the following:
Copy code
define('Test.Extension', [
    'OrderWizard.Module.Confirmation'

], function (
    OrderWizardModuleConfirmation
) {
    console.log('Load');
    
    return OrderWizardModuleConfirmation.extend({
        render: function () {
            console.log('Render');
        }
    });
});
I've add it to distro and can confirm it runs as I see 'Load' in the console on load. However, if I place an order, I do not see the 'Render' in the log.
s
Normally you extend core modules by modifying its prototype
Copy code
mountToApp: function(application)
{
  HomeView.prototype.greet = function()
  {
    console.log('Salutations!')
  }
};
I used to have a very basic web page on the developer portal about this but I never migrated it but you can find a cached version here: https://web.archive.org/web/20200929162200/https://developers.suitecommerce.com/nine-essential-customization-tidbits-for-beginners
c
Nice, thanks @Steve Goldberg. For future reference, I went with something like this:
Copy code
define('Test.Extension', [
    'OrderWizard.Module.Confirmation',
    'jQuery'
], function (
    OrderWizardModuleConfirmation,
    jQuery
) {
    return {
        mountToApp: function (application) {
            // Save the original render method
            var originalRender = OrderWizardModuleConfirmation.prototype.render;

            // Override the render method
            OrderWizardModuleConfirmation.prototype.render = function () {
                console.log('Extension render called');

                // Call the original render method to avoid recursion
                originalRender.apply(this, arguments);
            };
        }
    };
});
s
Yeah I guess that'll work. Normally, if you want to modify the original method we would use the _.wrap method but yeah that looks fine too
c
What would the main difference between mine and using _.wrap?
s
Honestly probably nothing