Reputation: 47
This code works in computer browsers but it does not work on iPhone. I will be very happy if you can see and tell me the problem. What can the reason be?
<ol style="margin: 0px; padding: 0px; display:inline-block" id="update" class="timeline">
<form id="begenform" action="#" method="post">
<input type="hidden" id="feedid" value="<?php echo $feed[$i]['i']; ?>"/>
<input type="hidden" id="userid" value="<?php echo $_SESSION['u']; ?>" />
<input type="hidden" id="i" value="<?php echo $i; ?>" />
<?php if(!empty($liked['u']))echo"<span style='color:#cd2122'>Beğendin</span>"; else echo '<input id="begenbutton" type="submit" class="likesubmit" value="Beğen" />'?>
</form></ol>
<script type="text/javascript" >
$(function() {
$(".likesubmit").click(function()
{
var gideni = $("#i").val();
var userid = $("#userid").val();
var feedid = $("#feedid").val();
var dataString = '&userid='+ userid + '&feedid=' + feedid + '&gideni=' + gideni;
$.ajax({
type: "POST",
url: "profilelike.php",
data: dataString,
cache: false,
success: function(html){
$("ol#update").append(html);
$("span.like").text("Ok");
}
});
return false;
}); });
</script>
Upvotes: 0
Views: 171
Reputation:
You need to listen for the "touchstart" and "touchend" events:
$('.myElement').bind("touchstart", function(e){alert('Clicked!')} );
My implementation:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#begenform').bind('touchstart click', function(e) {
e.stopPropagation();
e.preventDefault();
var gideni = $("#i").val();
var userid = $("#userid").val();
var feedid = $("#feedid").val();
var dataString = '&userid='+ userid + '&feedid=' + feedid + '&gideni=' + gideni;
$.ajax({
type: "POST",
url: "profilelike.php",
data: dataString,
cache: false,
success: function(html) {
$("ol#update").append(html);
$("span.like").text("Ok");
}
});
return false;
});
});
</script>
<form id="begenform" method="post" action="#">
<input id="begenbutton" type="submit" class="likesubmit" value="Beğen" />
</form>
For me works fine. Try it :)
Upvotes: 1