Questions tagged [knockoutjs]

Denotes questions related to Knockout use in Magento2

Filter by
Sorted by
Tagged with
0
votes
0answers
17 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
71 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
330 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
731 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
110 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
225 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
300 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
89 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
579 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
485 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
685 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. ...
5
votes
2answers
693 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
876 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
928 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....
2
votes
1answer
947 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
700 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
118 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 ...
2
votes
1answer
338 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
232 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
317 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
340 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
89 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
92 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
2k 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
594 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
256 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
34 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
21 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
204 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
296 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
243 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
111 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
303 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
125 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
389 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
636 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
593 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
1answer
476 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 ...
1
vote
1answer
441 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
974 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
107 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.
0
votes
1answer
504 views

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
55 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
74 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
99 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 ...
4
votes
2answers
399 views

Magento 2.2.4 = How to add new link 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 I want to add a link name as "Create an ...
0
votes
2answers
898 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
221 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 ...