04.07.2019 Views

frontend-developer-1

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Customize and Create JavaScript<br />

How can you add new methods to a jQuery UI Widget? How can a<br />

jQuery UI Widget method be wrapped with custom logic?<br />

There are two ways to implement this. If the business requirements dictate<br />

modifying something already in use (like the product page tabs), a different<br />

approach must be used than if you are creating something new (and have the<br />

capacity to specify a new component).<br />

We will address modifying an existing piece of functionality first. This is done by<br />

creating a mixin—a <strong>frontend</strong> parallel to interceptors (plugins).<br />

To override an existing Magento jQuery UI widget:<br />

//app/code/SwiftOtter/Test/view/<strong>frontend</strong>/requirejs-config.<br />

js<br />

var config = {<br />

"config": {<br />

"mixins": {<br />

"mage/tabs": {<br />

'SwiftOtter_Test/js/tabs-mixin': true<br />

}<br />

Copyright © 2018, SwiftOtter, Inc.<br />

72

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!