Questions tagged [knockoutjs]

Denotes questions related to Knockout use in Magento2

Filter by
Sorted by
Tagged with
1
vote
1answer
185 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
205 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
53 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
206 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
2k 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
178 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
38 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
20 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
119 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
50 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
573 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
111 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
81 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
1answer
112 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
62 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
270 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
83 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
41 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
167 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
125 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
122 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
743 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
272 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
34 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
603 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
208 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
52 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
283 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
525 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
104 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: ...
1
vote
0answers
195 views

Magento 2 Knockout Js Customer Name update issue after changing customer name

I am having strange issue. In header, along with Welcome message i am showing Customer full name. For that i am using knockout.js concept. <?php if($block->customerLoggedIn()): ?> <li ...
0
votes
0answers
278 views

knockout-js-uncaught-typeerror-unable-to-process-binding-isloading-is-not-defined

I am working on one step checkout, i searched but unable to find its solution, shipping address is not loading properly and console shows this error Uncaught ReferenceError: Unable to process ...
0
votes
1answer
62 views

Magento2: Translate knockout variable with odd beahaivor

I want to translate a variable in Knockout <span id="sales_unit" data-bind="i18n:sales_unit"></span> sales_unit has the value pair. The value should be translated to a different language ...
0
votes
1answer
539 views

Magento 2: Cannot read property 'dialog' of undefined, 'timepicker' of undefined,'RFC_2822' of undefined

Sometimes I'm getting following errors in the console after reloading the page:- Cannot read property 'dialog' of undefined Cannot read property 'timepicker' of undefined Cannot read property '...
0
votes
1answer
33 views

How to understand KnowkOutJs in Magento 2?

How to understand KnockOut Js in Magento 2 ? I am working in Checkout and cart page, I debugged a lot but i am not able to understand any single line code of KnockOut Js But without Magento 2, I am ...
0
votes
1answer
386 views

Magento 2 Add error/success message with knockout

I get error: Cannot read property 'addSuccessMessage' of undefined When I want to add a success or error message via knockout js to magento 2. I did: define([ 'jquery', 'Magento_Ui/js/...
0
votes
2answers
571 views

Knockout.js What is the correct way to reference $parent on js file?

I am new on Knockout.js, especially on how to use it in the Magento way. I create a custom ViewModel with a js file called storepickup-select.js and an HTML template called storepickup-select.html. ...
4
votes
2answers
591 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
670 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
713 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....
1
vote
1answer
812 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
573 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
87 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 ...
1
vote
2answers
1k 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 ...
0
votes
0answers
21 views

Magento 2 : Unable to destroy jQuery loader in js file

I want to destroy jquery loader in a js file function returning something like underscrore object. This function is called in html file using knockout binding. Not getting how to do that. This is the ...
2
votes
1answer
258 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
211 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: { ...
2
votes
0answers
294 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
300 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 ...