I found a great answer on detecting a click outside a div from this question: How do I detect a click outside an element?, which works fantastically.
But I\'ve noticed
var doc = document.documentElement;
doc.addEventListener('click', function (e) { //TODO();});
The trick:
/*Add this line into only mobile css*/
body{cursor:pointer}
this worked for me :)
$('html').on('touchstart', function(e) {
$('.navbar-flyout').hide();
})
$(".navbar-flyout").on('touchstart',function(e) {
e.stopPropagation();
});