twbs / ratchet

Build mobile apps with simple HTML, CSS, and JavaScript components.
http://goratchet.com
MIT License
14.63k stars 1.45k forks source link

Long touch in iOS result sometime in new Safari window opening #824

Open Marvin256 opened 8 years ago

Marvin256 commented 8 years ago

Hello

I'm using Ratchet on an iOS 9 web app and I have a bug that happens sometime: When a user does a long touch on a link, the new page is opened in a new window like a it was a target="_blank" link.

ex:

<a href="ageGate.html" data-transition="slide-in" id="step_home">

I'm using jQuery & Jquery Touch.

Does anyone had this behavior?

Thank you for your help

kamihouse commented 8 years ago

@Marvin256, using Ratchet 2.0.2 (note that the version of the "master" have changes over the labels), it is possible to solve with the code below.

With jQuery:

$(document).on('click', 'a[href]', function(event) {
    event.preventDefault();
});

Without jQuery:

var a = document.querySelectorAll('a[href]');
for (var i = 0; i < a.length; i++) {
    a[i].onclick = function() {
        return false;
    }
}