Questions tagged [knockoutjs]

Denotes questions related to Knockout use in Magento2

Filter by
Sorted by
Tagged with
6
votes
2answers
1k views

Magento 2 : How to call text/x-magento-init on Ajax success

I am in need to trigger some script with "text/x-magento-init" on ajax call but I am unable to do so. trigger('contentUpdated') contentUpdated is also not working in my case. I am using ...
4
votes
1answer
2k views

How to pass a Magento 2 variable to KnockoutJS

I want to pass $vendor_city to knockoutJS: <?php $vendor_city = $vendor->getData('city'); ?> <div id="m2-component" data-bind="scope:'ko'"> <script type="text/x-magento-init"&...
2
votes
1answer
2k views

How to extend sidebar.js to perform action on Qty change in Minicart Magento 2

I added a text field Box in minicart that need to perform some calculation on keyup to update Qty. I Added box field by modifying module-checkout/view/frontend/web/template/minicart/item/default....
3
votes
1answer
2k views

Magento 2 How to set value to UI component hidden field using Jquery or Javascript

I want to fill value in to ui component hidden field using Jquery or Javascript. Below is my code. Namespace/Modulename/view/adminhtml/ui_component/sampleimageuploader_image_form.xml <field ...
1
vote
4answers
1k views

I want to translate “Buy” and “save” word in tier_price.phtml file. magento 2

I want to translate "Buy" and "Save" word in tier_price.phtml file.I have added the word in translation csv file but it is not working form me. Refer screenshot PATH : vendor/magento/module-...
1
vote
1answer
348 views

Execute JS after cart is updated?

I'm a bit lost. I have a component that sits in the minicart that should update when the cart changes (so when subtotal changes). Now I know you have events but I need to fire a JavaScript function ...
2
votes
2answers
3k views

How to pass data from PHP to JavaScript component

I've overridden the grand-total element in checkout_cart_index layout and in my custom component JS I need to get the data that I have in a PHP class with a specific logic. How can I get the data ...
2
votes
1answer
858 views

Knockout js child components

I am making a custom module before adding a product on cart with 3 options : The upload option should display an upload form like : My initial idea was to make two knockout components : ...
2
votes
0answers
403 views

Magento 2 afterRender ko binding loses customer scope

I have a custom block rendered in header which displays the customer's available credit limit. <div data-bind="scope: 'customer'"> <div class="store-credit-limit" data-bind="style: { ...
3
votes
1answer
569 views

Injecting and calling custom knockout component in another component

I am using 2 components for multi-select and select input fields. Multiselect component - define([ 'underscore', 'uiRegistry', 'Magento_Ui/js/form/element/multiselect', 'Magento_Ui/...
5
votes
1answer
688 views

Magento2 : Issues in default Enterprise Edition RMA extension

I am facing some issues in Magento2 EE default RMA extension. In create new return under "Return item information". 1) Form is not getting validated: reason to order, item condition, resolution ...
2
votes
1answer
128 views

Magento 2.2.5 custom js not working when I call it from phtml file using uiComponent

I have created admin form using uiComponent. I have called phtml file using <htmlContent name="html_content"> in xml file. I tired to call custom.js using below code but its not working. <...
0
votes
1answer
173 views

call custom phtml with Ajax or Knockout in magento admin order detail page

anyone know how we can call custom phtml in order detail page admin side.
3
votes
2answers
4k views

How to initialize a block loader on an element which is being loaded by knockout.js in Magento 2?

I'm trying to implement a "block loader" animation on the cart summary element on the cart page while the cart totals are loading. The template file which loads this is Magento_Checkout/templates/...
1
vote
1answer
1k views

Magento 2 Knockout XML->PHTML->JS->HTML

I want to display static block in html login popup during checkout, but there is a problem. This is the html template which is called from js, this js is called from phtml, and this phtml template ...
1
vote
1answer
403 views

How to bind the image in ko template

I have image tag in phtml file .. And also i got the value of images and media url from ajax call . How to bind it like that in ko template <img alt="<?php echo $sizeGuideImage->getAlt() ?&...
0
votes
1answer
38 views

home page in magento2

I have created home.js file using require-config.js for HomePage. And init that home.js file in home.phtml file for Home Page. But i need to get the function that inside the home.js file into size....
2
votes
0answers
22 views

Trigger code on every popup

I wrote a specific code but it should run only when a popup is on. Not only a specific popup but all the popups on the site. How can I achieve it?
3
votes
0answers
438 views

Magento 2 : Data binding in Payment Method Selection

I want to display a custom field in "cash on delivery" payment method. I have created a custom module for this. But the field displays in all payment methods. Here is my code html <div class="...
0
votes
1answer
489 views

Any ideas on how to remove a knockout template from M2 (at the checkout)?

The template in question is vendor/magento/module-sales-rule/view/frontend/web/template/payment/discount.html and it shows at the checkout The rule that places the template in vendor/magento/...
0
votes
1answer
377 views

Magento 2.2.5: Custom checkout

I'm working on Custom Checkout Module. I've Created a Custom module follow this devdocs: https://devdocs.magento.com/guides/v2.2/howdoi/checkout/checkout_customize.html and everything is working ...
0
votes
2answers
183 views

how to switch cart items & totals table?

how to switch positions of cart items & totals table, move cart items to the top and then totals table to the bottom <!-- ko foreach: elems() --> <pre data-bind="text: ko.toJSON(...
0
votes
1answer
684 views

Magento 2 :What is the different between invalidate and reload if they both update the sections?

If some section should be updated then customerData.invalidate(sections) if you sure, that you really need update some section you can always do something like this: customerData.reload(['cart'], ...
0
votes
1answer
179 views

Product view error in admin panel Magento 2

Not able to view the product in the admin panel. getting below error in console. Unable to process binding "if: function(){return label }" Message: label is not defined I am not finding any fix for ...
1
vote
1answer
818 views

Magento2 - Wait for checkout page completely loaded and fire JS code

The goal is to add a piece of JS to manipulate a datepicker on the checkout page. I use a OSC (OneStepCheckout from mageplaza). So far I've followed this documentation and added this mixin: var ...
1
vote
1answer
1k views

Magento 2 : What is use of observableArray in JS file with knockout JS?

I have checked observableArray word declared in js file at top position. I have been seen this function like this items: ko.observableArray([]). Is this function related to AJAX while response is ...
0
votes
1answer
1k views

Magento2 : How to display custom values in checkout page

I am working on checkout page, I have pass some array values to checkout config provider. How to get those values in knockout JS and display by knockout html. Want to display all applied codes in ...
0
votes
2answers
952 views

How to observe checked event for different radio button groups?

I have created a new checkout step in which each product is listed along with the option to select which delivery method to use normal shipping or store pickup. I have displayed the product ...
2
votes
1answer
832 views

Magento 2 : From where (PHP) is the checkout billing address options drop down being populated?

From where is the checkout billing address options drop down being populated? How can I control the options? EDIT: Found root/vendor/magento/module-checkout/view/frontend/web/js/view/billing-...
3
votes
0answers
2k views

mageInit KO binding not working for a custom jQuery widget

I can't get the mageInit binding to work on a custom jQuery widget which I have created. I have used it in my KO template like: <div data-bind="mageInit: {'mywidget':{'configuration-value':true}"&...
1
vote
0answers
154 views

How to change Magento 2 checkout shipping radio button to dropdown

I need to change the format of displaying shipping methods as radio button to dropdown.
1
vote
1answer
882 views

Magento 2 : how to clear selected Value form Custom UI Component select(Dropdown)

Custom ui component select(Dropdown) <select class="admin__control-select" data-bind=" event:{ change: selectOptionCategory(uid)}, attr: { name: inputName, id: ...
1
vote
0answers
74 views

How do I switch product pages using Ajax?

I need to implement a button on the product page to switch products (NEXT and PREV) without reloading the page (AJAX or KnockoutJS). Now I have ID NEXT and PREV product. Please tell me how it can be ...
5
votes
1answer
99 views

Magento 2, I Want to add or hide custom steps on checkout page

I have created 1 custom tab on the checkout page and it's working fine I follow below link to add the tab on cart page. Magento 2 - Add step on checkout Then after I have added a Create an account ...
3
votes
0answers
187 views

Magento 2 Shipping method additional section reload

I want to display a custom message in shipping method section. The message is displayed based on the country and cart weight. I have created a custom block in shipping method section. Now it is ...
6
votes
2answers
719 views

How to add new link on checkout page in Magento 2.2.4?

I have created 1 custom tab on the checkout page and it's working fine I follow below link to add the tab on cart page. Magento 2 - Add step on checkout I want to add a link name as "Create an ...
1
vote
1answer
1k views

Binding Events On Dynamically Generated DOM Elements Knockout + Magento 2

I am working on a module where i have generated few DOM elements dynamically. But when i am trying to call certain function on some events then its not getting called. Here is the code sample. Here ...
2
votes
0answers
312 views

How do I show and hide cart items in the order summary sidebar of the magento 2 checkout?

I would like to display cart items in the order summary sidebar during the shipping stage with no show/hide toggle functionality. Then on reaching payment methods stage display the cart items in the ...
1
vote
3answers
3k views

Use getTemplate() within KnockoutJS foreach

I get the following error when I try to use getTemplate() within KnockoutJS foreach. Message: Unable to process binding "with: function(){return getChild('my-child') }" Message: getChild is not ...
1
vote
1answer
2k views

How to update DOM element in Knockout Js

I am building a custom payment method in Magento 2 where i need to show the EMI option based on card selection. I am able to render EMI option dynamically on Load but the EMI option is not getting ...
0
votes
1answer
189 views

Wishlist.js calling after span append Magento2

<!-- ko if: wishlist().counter --> <span data-bind="text: wishlist().counter" class="counter qty"></span> <!-- /ko --> The issue I am facing is that in the ...
2
votes
1answer
81 views

Zoomed image didn't close in Magento 2.2.3 and 2.2.4

I have just installed Magento 2.2.3 in my system. I have also added few categories and that of products. I can see a bigger image when I have clicked on it and it has been closed when I clicked on "X" ...
3
votes
1answer
1k views

How to override js functions which is inside the return in magento 2(mixins)

I need to override the setPaymentMethods() function in below js using mixins. Please provide me a solution to override the function which is the return value of the js magento/module-checkout/view/...
3
votes
1answer
688 views

Custom Checkout Validation: two fields must have the same value validation

I created two custom password fields, the confirm field should check if the value is the same as .create-password-field. I saw that Magento 2 uses equalTo but I can't get that to work in a uiComponent ...
1
vote
0answers
32 views

Magento2 - Custom Payment Method - standard approach to show dynamic data on payment method

What is the best way to show dynamic data (i-e pending balance or something) on payment method at checkout page ? Here is the screenshot for further reference. USD 1000 is the dynamic value which i ...
2
votes
1answer
2k views

Custom fields checkout checkbox toggle required?

in the Magento 2 checkout I added 3 custom fields, a checkbox that shows the customer two password fields that are used to create an account. Since the checkbox toggles if the fields are visible or ...
2
votes
1answer
674 views

Overwrite third party template file in my custom module

I have done some research to this subject but couldn't seem to find a detailed answer. What I need To overwrite a template file from a third party module in my case: Amasty One Step Checkout ...
1
vote
2answers
2k views

Magento 2- How to translate text in Knockout .html file

I want to translate KO text. "You have no items in your shopping cart." "Empty Basket" Already tried with translate.csv it doesn't work. Is there any way to translating knockout template text in ...
0
votes
0answers
119 views

The best way to add an extra attribute to checkout shipping form fields

I want to know the best way to add some extra attributes ('disabled' & 'readonly') in shipping checkout form. I found some workaround to bind a js in knockout but my js is loaded before the form !...
0
votes
1answer
64 views

Magento 2 : Form Component changes through component are ignored

I think there is a "changed" event somewhere that needs to be called, but I don't know what element or component, here is my code: requirejs(['jquery', 'uiRegistry', 'underscore'], function($, ...

1
5 6
7
8 9
14