Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [knockoutjs]

Denotes questions related to Knockout use in Magento2

1
vote
0answers
15 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
24 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
17 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
30 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
9 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
32 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
29 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
31 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
18 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 ...
0
votes
0answers
31 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
93 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"> &...
0
votes
0answers
20 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
20 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 ...
0
votes
0answers
25 views

Concatenate syntax to call static block in knockout template on Magento 2

I want to combine variables on shipping-method-item.html template to call CMS static block dynamically depending on shipping method name. I tried this but it doesn't work : <span data-bind="html: ...
1
vote
2answers
53 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
33 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
10 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
11 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
63 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
38 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
0answers
13 views

How to prefill a UI component (ui-select) with custom data?

I'm trying to prefill a ui-select in the checkout address creation form (customer with no address) with the prefix (gender) chosen in account creation, In Magento, I think the field selects the first ...
0
votes
1answer
30 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: ...
0
votes
0answers
18 views

Event is loading multiple times when click on button?

In Magento2, when I click on delete address on addressbook , the event is loading mutiple times. When i Click on Delete address it will show a popup and then if click on Cancel (4 times), then the ...
1
vote
0answers
62 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
99 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
20 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
0answers
29 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
22 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
43 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
78 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
96 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
154 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"&...
1
vote
1answer
48 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
82 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 ...
0
votes
0answers
41 views

Magento 2.2.5 How to add quantity to a new step of checkout page?

I have a new step on the checkout page with products. Right now I can add products to cart, but product quantity indicated in the code. I want to add qty buttons to checkout page so that the user can ...
1
vote
4answers
95 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-...
0
votes
0answers
24 views

Knockout Template Binding Not Updating UI

The if function in my template doesn't get run after showCustomOptions is changed. Template <ul class="configurator__options configurator__options--custom" data-bind="foreach: customOptions">...
0
votes
0answers
15 views

Re initialize Knockout template on some condition

I want to re initialize datepicker on the basis of zip code entered in checkout page Shipping section. How can I re initialize knockout js and template again and again on the basis of zipcode ? ...
1
vote
1answer
30 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 ...
0
votes
0answers
33 views

Creating an Owl Carousel with the Recently Viewed Products widget

I've created a custom container to hold a Recently Viewed Products widget but I would like it to become an Owl Carousel. I've overriden vendor/magento/module-catalog/view/frontend/web/template/product/...
0
votes
2answers
48 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
15 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
80 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 : ...
1
vote
0answers
58 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: { ...
1
vote
0answers
31 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/...
0
votes
0answers
33 views

Set required for VAT field for a specific store in magento 2 checkout

I have a Magento 2 store with more than one store view. I want to show the VAT field on checkout, but it has to mandatory for specific store view. What i have done: Store -> Configuration-> Customer->...
5
votes
1answer
99 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
34 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
36 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
257 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/...