Browsed by
Tag: javascript

How to initialize a block loader Magento 2

How to initialize a block loader Magento 2

Did you want to add loader into **templates/cart/totals.phtml** These some ways to add loader spinner into block or page. 1 Use: <div data-bind=”blockLoader: isLoadding”> /** Block Content HTML */ </div>, with this option you should add **isLoadding : ko.observable(false)** into your Component Example: Block XML Define <block class=”Magento\Framework\View\Element\Template” name=”block-name” template=”Namespace_ModuleName::templates.phtml”> <arguments> <argument name=”jsLayout” xsi:type=”array”> <item name=”components” xsi:type=”array”> <item name=”scope_name” xsi:type=”array”> <item name=”component” xsi:type=”string”>Namespace_ModuleName/js/componentjsfile</item> </item> </item> </argument> </arguments> </block>   Block templates.phtml CODE <div id=”abc-def” data-bind=”scope: ‘scope_name'”> <div class=”product-wizard-selections” data-bind=”blockLoader: isLoading”>…

Read More Read More

How to override Magento 2 js using Mixins?

How to override Magento 2 js using Mixins?

A Magento 2 RequireJS “mixin” allows you to programmatically listen for the initial instantiation of any RequireJS, How to mixins in Magento 2 work? First, create requirejs-config.js var config = { config: { mixins: { ‘Magento_Checkout/js/model/quote’: { ‘PackageName_ModuleName/js/plugin-quote’: true } } } };   Magento_Checkout/js/model/quote js file you want to rewrite. PackageName_ModuleName/js/plugin-quote target file. plugin-quote.js /*global define*/ define([“jquery”], //defile more js here function ($) { ‘use strict’; var mixins = { getTotals: function () { //Define new content for getTotal() function…

Read More Read More

Follow by Email
Facebook
Facebook
LinkedIn