Ho riscontrato un problema con jQuery 1.6.4, iOS 5 e la registrazione di eventi touchstart/touchend (come indicato nel titolo, ovviamente).eventi jQuery su iOS 5
Prendere il seguente codice:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="mmpa/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var $body = $('body');
$('<button>').html('test jQuery').bind('touchstart', function() { alert('touchstart'); }).appendTo($body);
});
</script>
</head>
<body>
<button ontouchstart="alert('touchstart');">test pure JS</button>
</body>
</html>
Il pulsante "puro JS" mostra l'avviso di iOS 4.3 e iOS 5, ma il pulsante "jQuery" funziona solo su iOS 4.3. Testato su simulatore iPad/iPhone, 4.3 e 5; testato anche su iPhone 4, iPhone 5.0 e iPad 5.0 reali. Stessa reazione se uso uno <input type="button">
o anche un semplice <a>
anziché uno <button>
.
È un problema correlato a jQuery come credo?
non usare bind ('TouchStart') e ontouchstart = "". Usane uno e preferisci non usare javascript in linea. –
Questa era una dimostrazione del concetto per mostrare che JS in linea funziona quando jQuery no. Ovviamente non uso mai, mai usato JS inline in codice reale. – Cyrille
Sono stato in grado di produrre questo errore con jQ 1.5.2 e l'evento click, quindi forse dovresti modificare il titolo in qualcosa come "jQuery Events su iOS 5" – webXL