0

If I add in checkout inside the component's template something like this: <a href="#" data-bind="click: myFunction()"></a> with a console.log('myFunction executed') in component's function 'myFunction', than it will log the message on page refresh.

I'm trying this on Magento 2.2.6.

This should not happen. Anyone knows why it does ?

I don't have other code that will trigger click event. I got this in onother component too. It seems like every click binding is executed on initialize or something.

Change bindings are not called on page refresh, just 'click'.

0

Found the problem.

It should be:

<a href="#" data-bind="click: myFunction"></a>

or if it needs $parent context than:

<a href="#" data-bind="click: myFunction.bind($parent, parameter1, parameter2, ..)"></a>

Found the answear here: https://mage2.pro/t/topic/1937

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.