Reputation: 5367
I have the function below that works perfectly fine on all browsers. However, the function (which is used to log a user out essentially) doesn't work on the iPad(v3). Note this is a web-app.
My initial thought was it's window.location
, which I've heard doesn't function well on iPad. But I tried location.href
and window.location.href
as well to no avail.
No console errors or strange behaviour.
Anyone experience any similar issues?
$(document).on('touchstart click', '.sb-sign-out', function (e) {
e.stopPropagation(); e.preventDefault();
$.post('@Url.Action("clientLogout", "master")', {}, function () {
window.location = "@Url.Action("campaigns", "master")";
});
});
Here's the DIV:
<div class="sb-sign-out button round">LOGOUT</div>
Upvotes: 3
Views: 253
Reputation: 3194
I think the best way to make this work reliable is via the 'tap' event handler in jquery mobile, for example: $(document).on('click tap', elem, function (e) {});
see here: http://api.jquerymobile.com/tap/
for normal jquery this plugin would give you equal abilities: http://plugins.jquery.com/tap/
the problem with touchend is that if someone touches the button, then decides to not log off and move the finger away from the button, it gets triggered although not wanted...
Upvotes: 1
Reputation: 5367
This issue, as mentioned in comments above, was that all non a-href buttons should be using touchend
versus touchstart
. This fixed my issue.
$(document).on('touchend click', '.sb-sign-out', function (e) {
e.stopPropagation(); e.preventDefault();
$.post('@Url.Action("clientLogout", "master")', {}, function () {
window.location = "@Url.Action("campaigns", "master")";
});
});
Upvotes: 2