Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Magento 2 Development Quick Start Guide

You're reading from   Magento 2 Development Quick Start Guide Build better stores by extending Magento

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781789343441
Length 218 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Branko Ajzele Branko Ajzele
Author Profile Icon Branko Ajzele
Branko Ajzele
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Understanding the Magento Architecture FREE CHAPTER 2. Working with Entities 3. Understanding Web APIs 4. Building and Distributing Extensions 5. Developing for Admin 6. Developing for Storefront 7. Customizing Catalog Behavior 8. Customizing Checkout Experiences 9. Customizing Customer Interactions 10. Other Books You May Enjoy

Extending jQuery widget components

Assuming we wish to extend the redirectUrl component instead of replacing it completely, we can do so in a similar fashion. The entry in our requirejs-config.js remains the same, whereas the difference lies in how we edit our redirect-url.js file:

define([
'jquery',
'jquery/ui',
'mage/redirect-url'
], function ($) {
'use strict';
$.widget('magelicious.redirectUrl', $.mage.redirectUrl, {
/* Override of parent _onEvent method */
_onEvent: function () {
// Call parent's _onEvent() method if needed
return this._super();
}
});
return $.magelicious.redirectUrl;
});

Using the _super or _superApply is a jQuery widget way of invoking methods of the same name in the parent widget. While this approach works, there is a more elegant solution called mixins.

The Magento mixins for JS are much like its plugins...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime