2

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?

1 Answer 1

0

Instead of adding new events you can subscribe to each input value as all those are knockoutjs observable elements

5
  • Do you maybe have an example of how I would to something like that? Commented May 30, 2018 at 9:37
  • yes @Sanne this is documented in knockoutjs.com/documentation/observables.html Commented May 30, 2018 at 9:43
  • Ah thanks, hmm in the docs they do something like 'myViewModel.personName()' how would i do something like that in Magento_Checkout/js/view/shipping.js? (i made a mixin for it) I'm unsure what how i could access the view model for that js. Commented May 30, 2018 at 10:03
  • I did see that you can access this.source.shippingAddress.firstname but i'm not sure if that is exactly what you mean? Commented May 30, 2018 at 10:17
  • you can subscribe to this input and get to know whenever value changes Commented Jun 6, 2018 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.