Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have PhoneGap-iOS Application for iPad where User will get Logout Popup as shown in Image below.

Logout popup

I want this popup to hide when User clicks on Body. My code which works on native browser is not working on iPad Simulator.

$("body").ClickOrTouch(function (evt) {
    if (!(evt.target.id == "launchUsername") {
        $('#launchLogout').hide();
    }
});
share|improve this question
Did you try on a real iDevice? – Bigood May 15 at 8:07
I have tested it on Real Device too.. – Prossi May 15 at 8:58

This question has an open bounty worth +250 reputation from Sidharth Shah ending in 2 days.

This question has not received enough attention.

3 Answers

Maybe event.touches[0].target can do it on mobile safari ( You've got the touches array in order to manage multitouch events, one by finger). As discussed in this topic : Mobile Safari - event.target in touch event

But I think it's worth to try with jquery-ui-touch-punch.

It's what I use to manage touch events with jquery on mobile web app (such as cordova/phonegap)

Very simple : simply adding this library makes any touh event behave like mouse events.

(touch down/up => mouse down/up, single press => click etc... )

share|improve this answer
I will try to use jquery-ui-touch-punch. But I wanted to know what went wrong with above code when I test it on iPad Simulator – Prossi May 15 at 8:45
hmm not sure if its 'clickOrTouch' without the capital 'C' ? – Guian May 15 at 8:54
the ClickOrTouch Event gets executed. Just the event.target shows undefined every time. – Prossi May 15 at 8:59
yep, according to jquery documentation, target should be normalized for cross-browser... source : api.jquery.com/category/events/event-object/…) – Guian May 15 at 9:43
So How can i do that normalization? any suggestions – Prossi May 15 at 9:50
show 1 more comment

have you tried a different event yet? something like that maybe?

$("body").on('touchend', function (evt) {
    if (!(evt.target.id == "launchUsername") {
        $('#launchLogout').hide();
    }
});
share|improve this answer
$("body").on('touchend', function (evt) {
    if (!(evt.target.id == "launchUsername") {
        $('#launchLogout').hide();
    }else{
evt.stopPropagation();

}


});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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