- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2018
02:21 AM
05-30-2018
02:21 AM
Adding events to input on checkout
I'm trying to add an event like 'keyup: validationSuccess' to all input fields on the checkout. I have overwritten input.html and added the Js to Shipping.js but now when i go to checkout/cart.html I get an error because of course the validationSuccess function doesn't exist on the Cart JS. So I need the function on all inputs on the Checkout but not on the Cart so overwriting input doesn't work. How do I do this the right way?
Labels:
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2018
02:53 AM
05-30-2018
02:53 AM
Re: Adding events to input on checkout
You can do it in your overriden input.html file be setting conditions,
Final code will be,
<!-- ko if: window.checkoutConfig.checkoutUrl.replace(/(\/#|\/|#)$/, '') == window.location.href --> <!-- for checkout page --> <input class="input-text aaaaaaaa" type="text" data-bind=" value: value, valueUpdate: 'keyup', hasFocus: focused, attr: { name: inputName, placeholder: placeholder, 'aria-describedby': getDescriptionId(), 'aria-required': required, 'aria-invalid': error() ? true : 'false', id: uid, disabled: disabled }" /> <!-- /ko --> <!-- ko ifnot: window.checkoutConfig.checkoutUrl.replace(/(\/#|\/|#)$/, '') == window.location.href --> <!-- for other pages --> <input class="input-text aaaaaaaa" type="text" data-bind=" value: value, valueUpdate: 'keyup', hasFocus: focused, attr: { name: inputName, placeholder: placeholder, 'aria-describedby': getDescriptionId(), 'aria-required': required, 'aria-invalid': error() ? true : 'false', id: uid, disabled: disabled }" /> <!-- /ko -->
If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2018
03:59 AM
05-30-2018
03:59 AM
Re: Adding events to input on checkout
I feel like there should be a better way using events and observables but i'm not sure what event get's fired on keyup?