Questions tagged [knockoutjs]

Denotes questions related to Knockout use in Magento2

1
vote
0answers
25 views

Magento 2 : How to load payment methods in shipping step?

I need to show payment methods in shipping step in Magento 2.3 checkout, I have added done changes to file checkout_index_index.xml, and also I have added html code to shipping.html file. But I still ...
4
votes
1answer
326 views

magento2 checkout: how to update billing address programmatically

I would like to force update of the billing address as user is typing his firstname and lastname in the checkout. For example when it changes or on keyup. I'm using a custom checkout module that ...
1
vote
1answer
182 views

Magento 2 Minicart content not displaying

I'm working on developing my own theme by extending the Magento Blank theme. I'm trying to add the minicart to my header.phtml file. I'm loading the minicart in my header like so: <?php echo $...
3
votes
1answer
61 views

Magento 2 : Store value in a variable via knockout loop in html

I am new to KO, in my html file I am printing a value like this - <!-- ko foreach: { data: JSON.parse($parent.options), as: 'option' } --> <!-- ko if: option.label === 'AAA' || option....
2
votes
2answers
30 views

What is the mean of This Code in js

what does the below coding mean? !-- ko foreach: getRegion('messages') --> <!-- ko template: getTemplate() --><!-- /ko --> <!--/ko-->
0
votes
1answer
32 views

Pass data between components

Assuming I got 2 components like this: How can I pass data from 1 component to another? In this example I would like to pass some data when I close the modal to "my-component" <script type="text/...
1
vote
0answers
29 views

Knockout binding js to template

I try render input field in my custom form element like <render args="ui/form/element/input"/> but then i get some js errors because elem userChanges and others dont exist(see https://github....
1
vote
0answers
19 views

Magento 2 Knokout.js remove element define in differen template file

I want to remove html element from template file using knockout.js code. I have write my code in shipping.js which is getting called on checkout page. In shipping.js under i have defined my variable ...
2
votes
0answers
117 views

Disable payment option in checkout when specific shipment is used via js only

I've disabled alost all payment modules when in store pickup i set as shippemnt. I'm using for this plugin for Magento\Payment\Model\Method\AbstractMethod and is working fine. Only one module payu/...
0
votes
1answer
34 views

How can we populate the default shipping address country and zipcode in cart page in magento 2 for logged in customers?

Can we populate the default country and postcode for the logged in users using their default shipping address of the customer to get shipping estimates?
1
vote
0answers
33 views

Magento 2.3 checkout page hang up due to knockoutjs or underscore

After Magento 2.2.4 upgraded to Magento 2.3.0 checkout page is not working. Checkout page hang up browser and showing browser warning to stop it. When clicking on stop it is showing some jquery ...
2
votes
1answer
42 views

Require custom checkout field from extension

I am using a zipcode(postcode) check extension that adds a custom zipcode and house number field. Now I want those to be required so they have to be filled in before going to the next step. ...
2
votes
0answers
163 views

How to update shipping methods on change of custom dropdown on cart page

I have created a custom dropdown above country dropdown on cart page. Now I want to update shipping methods list. I followed Devdocs to show custom field on address form (cart page). All in all I ...
0
votes
0answers
47 views

Magento2: how to add/remove a form field using javascript

I have created a custom form in admin in which I need to show buttons such as "Add more" and "Remove". The scenario is exact that which is discussed here: https://stackoverflow.com/questions/...
0
votes
0answers
140 views

Magento 2: Knockout js dynamic content binding repeats the same element

I have created a custom form in checkout page. It contains a drop down field and one ul list. By default there is few li tags(For example,4). When we change the dropdown the li tags will be changed( ...
1
vote
1answer
480 views

Magento 2: Knockout js dynamic content binding issue

I have created a custom form in checkout page. Everything works fine except one ajax response binding Here is my code template.html <form id="cust-checkout-form" class="form" data-bind="attr: {...
0
votes
0answers
185 views

Add custom jQuery code after checkout page load

I added some jquery code on checkout page but its not working as because the knockout component load after the page load and my jquery code not able to find that element(class or id) on which I have ...
1
vote
1answer
151 views

Magento 2 get store configuration in js

I'm trying to get admin store configuration (core_config_data) in mincart.js file. Is there any method to get this ? like define([ 'storeConfiguration' 'uiComponent', 'Magento_Customer/js/...
1
vote
3answers
585 views

Magento 2 override minicart.phtml in custom module

I'm trying to override minicart.phtml file from Magento2\vendor\magento\module-checkout\view\frontend\templates\cart\minicart.phtml to my custom module Magento2\vendor\XXXX\YYYY\view\frontend\...
1
vote
1answer
142 views

Magento 2 knockout js dynamic button title in minicart

I'm trying to add dynamic checkout button title in minicart using knockout js. Button title will be configured in admin configs. I configured in minicart.js But I dont know how to use/call in template ...
1
vote
1answer
115 views

Knockout js : Read parent of parent's data

I want to read the parent of parent elements data. But, I can't able to read it properly. My Array Screenshot : My Code : <!-- ko foreach: { data: Object.keys($parent.optionParam()[main_id]), as:...
0
votes
0answers
49 views

Custom live chat script not working in Magento 2.2.4

I have tried adding the chat script on .phtml of the custom extension which I have created for integrating my own live chat. But the libraries are showing undefined when the chat plugin loads the ...
0
votes
0answers
178 views

Magento 2 - (Shipping Address) Custom city dropdown validation not working in checkout page

I followed this link. I created a custom shipping method and I need the city to be required for my shipping rates to be calculated. My problem is my shipping-rates-validation doesn't get trigger it ...
1
vote
2answers
1k views

Magento 2 How to bind knockout event on ajax html response

I have created custom functionality on item form on cart page like increment/decrement qty, remove product with a custom popup, custom move to wishlist by knockout js. For knockout events, I created ...
0
votes
1answer
128 views

Magento 2.3 | Knockout.js - Unexpected end of input

I've installed the latest Magento Version (2.3) and everythign went well. The installation was completed and i was able to view and frontend aswell the backend. For some reason i get the following ...
0
votes
0answers
29 views

How to specify image path relative to module in Knockout HTML view?

I'm making a magento 2, usign 2.2.6, module trying to display certain information at the checkout and I'm stuck when trying to add an image relative to the module path. I'm NOT using PHTML in this ...
0
votes
0answers
17 views

How to add Ui file-upload on chceckout purchaseorder ofline payment

I'm trying to add file upload file thru ajax when user is on offline payment purchaseorder. I can put additional input overwriting Magento_OfflinePayments/js/view/payment/method-renderer/...
0
votes
0answers
102 views

Decode HTML Knockout JS - Minicart

I use HTML Code inside Custom Options. The Radio Option titles are for example <p class="style1">Option1</p> This way I can style my custom options in css, instead just plain text. ...
0
votes
0answers
30 views

Uncaught Error: Unable to process binding

In my Magento 2.1 website, I didn't change anything but suddenly getting this error in my console. Because of JS mini cart and checkout process is not working knockout.js:3012 Uncaught Error: Unable ...
0
votes
1answer
446 views

Autocomplete form field using Knockout Js on Magento2 Checkout

I have created a module to which autocompletes the city field of Magento. I am facing an issue which says TypeError: Unable to process binding "shippingAutoComplete: function(){return { ...
1
vote
0answers
84 views

Magento 2 : add google map in checkout

I want to add google map in Magento 2 checkout page. Added API url and key to phtml using below code <referenceContainer name="after.body.start"> <block class="Test\Vendor\Block\...
0
votes
1answer
61 views

Magento CE 2.2.2: How to add images to my custom payment plugin module?

I am creating a custom payment plugin for Magento 2.2.2 For the plugin I need to add the payment icons and some other images. How can I add images for my custom payment plugin? I tried all the ...
0
votes
0answers
80 views

Magento 2.x how to get ui-select selected value

I have place ui-select component and i want to get value in my custom component. How can i get selected value in custom component ? list.js file Here is my output.
0
votes
1answer
61 views

Magento 2 Auto added product's image missing in the checkout page

I have created a small module to add a product automatically at cart when a specific coupon code is applied. All is working fine except the product image is missing for the first time, but it shows ...
0
votes
0answers
236 views

Magento 2 how to write in data-mage-init

Magento uses below way to show Requistition list using "x-magento-init". <div class="block block-requisition-list social-button" data-bind="scope: 'requisition_ - 111'"> <!-- ko template: ...
0
votes
1answer
65 views

Magento 2: Details in checkout formatted with HTML-tags

For the title of an article, I am using HTML-code. Unfortunately, the HTML-code in the cart is not written as formatted in HTML – it is written with the HTML-tags, like: "This is a title.<br>...
1
vote
0answers
40 views

How to use javascript in ko template in magento 2?

I have a custom module which will overrride vendor\magento\module-checkout\view\frontend\web\template\shipping-address\shipping-method-item.html, here is the code <!-- /** * Copyright © Magento, ...
2
votes
1answer
128 views

How to return value from knouckout js Ajax call

I have a knouckout js to return data to html template. But I can't able to return values from ajax call done function. My knouckout js like below, define( [ 'jquery', 'mage/url', ...
0
votes
1answer
107 views

Add/Remove class from div if minicart hasitem/noitem

I want to add a class in parent div if minicart/cart is empty and remove same class if minicart/cart has an item(s).I made changes in minicart.phtml. below is my code for that. <div class="block ...
1
vote
0answers
92 views

Magento2: custom javascript not called when using with text/x-magento-init

In list.phtml (product listing) I am showing requistition lsit for every product using type="text/x-magento-init" in loop as: <script type="text/x-magento-init"> { "*": { "...
5
votes
2answers
544 views

How to debug in ko template in magento 2?

Here is the code in \vendor\magento\module-checkout\view\frontend\web\template\shipping-address\custom-method-item-template.html <tbody collapsible="as: '$collapsible_' + method.method_code"> &...
1
vote
0answers
201 views

Knockout foreach afterRender

how can I call afterRender after generating all foreach elements? I want to initialize slider after rendering all slides. I've tried: <div class="order__picker-dates owl-carousel" data-bind="...
1
vote
0answers
29 views

How to list Parent & Child Category BY Knockoutjs

I want to list category block By knockoutjs. Currently I Implemented By Direct PHP Code But I want to do by Knockout js. My Block code ---------- namespace QuickLearn\Knockout\Block; class ...
1
vote
2answers
481 views

how to trigger click event in M2

In my header section I have user name and if user have access to different location then he has button saying click me. I want to send ajax call on this button. But JS is not working. Can anybody help ...
0
votes
1answer
183 views

Magento2: Unable to reload customer cart section

I am using welpixel quick view extension for quick view on product listing, but due to some customizations I am unable to use it as it is. So I just used its url to get html and appended data using ...
0
votes
0answers
16 views

M2 js getUrl links randomly absolute or relative

I am not used to frontend development... We have a link like this: <a class="primary button" data-bind="attr: { href: getUrl('my-special-page') } href="my-special-page"> <span data-bind="...
0
votes
0answers
38 views

Magento 2 Custom JS Component detect/Observe changes from any form input in the DOM

I have ny Component as so: define(['uiComponent', 'jquery', 'ko', 'jquery/ui', 'mage/translate', 'Magento_Ui/js/modal/modal', '...
0
votes
1answer
218 views

Magento2: Get product date in Knockout Js

How to get special delivery end date in ko js I have implemented KO templated with Js How can I get Value of Product Special delivery date in JS for countdown <referenceContainer name="content"&...
1
vote
1answer
372 views

How to translate knockout string variables in Magento 2

I'm extending and translating a third party module which has the following in a template: <!--ko foreach: options--> <div class="option"> <label data-bind="i18n: label"></...
0
votes
1answer
91 views

Magento 2 - display custom product attribute instead of the price in minicart

I try to display a custom product attribute instead of the price in minicart. I saw that the html file that I have to override is price.html from module_checkout. price.html : <!-- ko ifnot: ...