i have a problem..
I have a index.php
file which have a div inside with the result of an ajax request:
<div id="content" style="margin-top:20px;" class="content_media"></div>
<script>
show_page('home'); HERE I CALL THE AJAX FUNCTION
</script>
<script type="text/javascript">
$(function(){
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
var eventType = isMobile ? "touchstart" : "click";
$( "#content" ).on(eventType, ".escort_id", function() {
alert(eventType);
var id = $(this).attr("id");
show_page('profilo',id);
});
});
</script>
Alsways in index.php
i call jquery, at the top of the page.
Then i have the response of the ajax request:
<div id="<?php echo $data['id'];?>" class="escort_id"></div>
The problem is that in mobile browser the "touchstart" event doesn't work, instead..on the desktop everything work perfectly..
[EDIT] Because i'm not a pro with javascript.. I made this script:
var flag = false;
$("#content").bind('touchstart click', ".escort_id", function(){
if (!flag) {
flag = true;
setTimeout(function(){ flag = false; }, 100);
var id = $(this).attr("id");
show_page('profilo',id);
}
return false
});
Because of the comment of mapek .. but what i have to put instead of $(this).attr("id");
?