Extending Native Events in SuiteCommerce

in , April 5th, 2024
A MacBook with lines of code on its screen on a busy desk

If you are a developer who works to customize SuiteCommerce websites, you'll find that adding or updating the defined events for a native SuiteCommerce view file is a common need. Doing it correctly is key. See the example below for how to safely extend events in SuiteCommerce.

define('ExtendEvents.Example', [
        'ProductDetails.Full.View' //load the view you wish to extend
    ],
    function (
        ProductDetailsFullView
    ) {
        'use strict';


        return {
            mountToApp: function (container) {
                    
                ProductDetailsFullView.prototype.events = _.extend(ProductDetailsFullView.prototype.events || {}, {
                    'some event': 'functionName'
                });
                
            }
        };
    });

Key Takeaways of Extending Native SuiteCommerce Events

“events” may not be defined on the object. Be sure to handle that by using code like:

ProductDetailsFullView.prototype.events || {}

You can change multiple things when extending events

  • Add a new event for a view. Be sure to define the function on the view prototype as well in this case.
  • Remove an event from a view.
  • Change the function an existing event is mapped to.
  • Change an existing event.

 Author: Sam Gagliardi


Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!


Oracle NetSuite Alliance Partner & Commerce Partner

If you have general questions about SuiteCommerce or more specific questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

We are a premium SuiteCommerce agency that creates powerful customer portals. Unlike our competitors, we have already solved your problems.

 
 

Want to keep learning?

Our team of NetSuite professionals has written articles on a wide variety of NetSuite topics, from SuiteCommerce tips, to recommended NetSuite solutions, to available support services, and more! 

Your cart