javascript - Touchstart Event delegation -


update: problem occurs on elements dinamically created have page load products in ajax grid. each product div want clickable add information cart.

all works fine using jquery click event page must used on mobile want use touchstart event how wrote doesn't work!

it seems event delegation doesn't work touchstart or else.

this code, in chrome or firefox in desktop page click works, if emulate mobile device touch doesn't work, ideas?

<div class="col-xs-12 col-md-offset-3 col-md-6 col-md-3 col-lg-offset-3 col-lg-6 col-lg-3 ">     <div class="tiles" id="products"></div> </div>  $("#products").on("click touchstart", ".product-tile", function (e) {     console.log("ok"); });  function getproducts() {     $.ajax({         type: "post",         contenttype: "application/json; charset=utf-8",         url: "/aj/productws.asmx/getlistjson",         data: "{ id_category: '<%= id_category%>' }",         success: function (data) {             var j = jquery.parsejson(data.d);             var products = '';             var colors = ["bg-blue-madison", "bg-purple-studio", "bg-green-meadow", "bg-grey-cascade", "bg-red-intense", "bg-green", "bg-blue-steel", "bg-yellow-lemon", "bg-red-sunglo"];                                      if (j != null) {                 (var = 0; < j.length; i++) {                     var colore = colori[math.floor((math.random() * 8) + 1)];                     products += '<div class="col-md-4 col-sm-4 col-xs-4"><div class="tiles-bar product-tile tile ' + colore + '" data-idproduct = "' + j[i]["id_product"] + '" data-name = "' + j[i]["name"] + '" data-price = "' + j[i]["price"] + '"><div class="tile-object"><div class="name">' + j[i]["name"] + ' € ' + j[i]["price"] + '</div></div></div></div>';                 }             }             $("#product").append(products);         }     }); } 

i found problem: resizing browser window @ different resolution saw neither click worked, looked @ computed properties searching have changed. property float elemente under div "product" under resolution unset, set manually have float left , magically problem disappeared. have problem touch works 2 times each touch story. followed @daniel shillcock promise hint if not problem. all


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -