osotorrio
osotorrio

Reputation: 1172

Knockout click binding not working in iPad

I have a simple button like this:

<button data-bind="click: login" type="button" class="btn btn-lg btn-primary">Log in</button>


ko.applyBindings({
    login: (viewModel, event) => {
        // this gets never called
    };
});

The click event is working fine in all devices I have tested it. Except iPad 9.3.5 (iPad mini)

Looking for answers I found the following work around: https://makandracards.com/makandra/34753-how-to-fix-ipad-does-not-trigger-click-event-on-some-elements

It did not work for me. Anyway idea of how to fix this?

Note: the jQuery click event is not working either.

Upvotes: 2

Views: 379

Answers (1)

Piotr Wicijowski
Piotr Wicijowski

Reputation: 2115

You are using arrow functions, which according to caniuse.com is supported on iOS Safari from version 10 onwards. You can change your code to the following:

ko.applyBindings({
    login: function(viewModel, event){
        // this gets never called
    };
});

or if your code uses more of the ES6 features, you can consider transpiling your code, e.g. using babel, or similar tools.

Upvotes: 1

Related Questions