简体   繁体   English

忽略尝试取消touchstart的尝试:fastclick警告

[英]Ignored attempt to cancel a touchstart : fastclick warning

I'm having the first popup on which another popup comes to select few fields. 我有第一个弹出窗口,另一个弹出窗口用来选择几个字段。 To show the second popup this is the code I'm trying: 为了显示第二个弹出窗口,这是我正在尝试的代码:

$("#select1").click(function(e) {
  e.stopPropagation();
  //$('#sellerModal').hide();
  var tmplData = {
    string:['Ready','2-3 Days','4-5 Days','1 Week','10+ Days']
  };
  $("#countTypePopupTemplate").tmpl(tmplData).appendTo(".maindiv");
  that.closePopup();
  $("#count_div").each(function() {
    $("#count_div").click(function(evt) {
      evt.stopPropagation();
      $("#select1").text($(this).text());
      $("#myCounttype").remove();
    });
  });
});

Here is the HTML template: 这是HTML模板:

<script id="countTypePopupTemplate" type="text/x-jquery-tmpl">
  <div id="myCounttype" class="popup1 layer-2">
    <div class="popup5">
      {{each string}}
      <div id="count_div" class="popup4 bottom-border">${$value}</div>
      {{/each}}
    </div>
  </div>
</script>

I'm getting a warning: 我收到警告:

Ignored attempt to cancel a touchstart event with cancelable=false, for example, because scrolling is in progress and cannot be interrupted. fastclick.js

Here I'm not able to click the 4 out of 5 elements in the second popup. 在这里,我无法单击第二个弹出窗口中的5个元素中的4个。 Only first 1 is clickable. 只有前1个可点击。 Snapshot of second popup. 第二个弹出窗口的快照。

在此处输入图片说明

I read all the blogs where the topic is disscussed. 我阅读了讨论该主题的所有博客。 But didn't got any solution working for me. 但是没有任何解决方案对我有用。 Looks like there is some corner case. 似乎有一些极端情况。

Your each function is pointing to id which makes you cannot click other buttons. 您的每个函数都指向id,这使您无法单击其他按钮。 You should use class to recognize the buttons. 您应该使用类来识别按钮。

$("#select1").click(function(e) {
  e.stopPropagation();
  //$('#sellerModal').hide();
  var tmplData = {
    string:['Ready','2-3 Days','4-5 Days','1 Week','10+ Days']
  };
  $("#countTypePopupTemplate").tmpl(tmplData).appendTo(".maindiv");
  that.closePopup();
  $(".pop_btns").each(function() {
    $(this).click(function(evt) {
      evt.stopPropagation();
      $("#select1").text($(this).text());
      $("#myCounttype").remove();
    });
  });
});

HTML template: HTML模板:

<script id="countTypePopupTemplate" type="text/x-jquery-tmpl">
  <div id="myCounttype" class="popup1 layer-2">
    <div class="popup5">
      {{each string}}
      <div id="count_div" class="popup4 bottom-border pop_btns">${$value}</div>
      {{/each}}
    </div>
  </div>
</script>

Try using some parent selector before $("#count_div").each(function() { $("#count_div").click(function(evt) { Like this $(".parent_class #count_div").each(function() { $(".parent_class #count_div").click(function(evt) { 尝试在$("#count_div").each(function() { $("#count_div").click(function(evt) {像这样的$(".parent_class #count_div").each(function() { $(".parent_class #count_div").click(function(evt) {

This will solve 1 time running each() for "#count_div" . 这将解决为"#count_div"运行each() 1次问题。

So the actual problem is each() is running only 1 time, that's why your first element that is Ready click event is working, not others. 因此,实际的问题是each()仅运行1次,这就是为什么您的第一个元素(即Ready click事件)可以正常工作的原因,而不是其他因素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 触摸移动卡住 忽略取消触摸移动的尝试 - Touch move getting stuck Ignored attempt to cancel a touchmove google map 缩放事件:忽略使用 cancelable=false 取消 touchend 事件的尝试 - google map zoom event: Ignored attempt to cancel a touchend event with cancelable=false 忽略尝试使用 cancelable=false 取消 touchmove 事件,例如因为滚动正在进行且不能被中断 - Ignored attempt to cancel touchmove event with cancelable=false,for example because scrolling is in progress and cannot be interrupted 取消当前触摸事件,直到下一次触摸开始 - Cancel current touch events until next touchstart 不安全的JavaScript尝试访问Safari中的帧警告 - Unsafe JavaScript attempt to access frame warning in Safari 将警告非被动事件侦听器反应到滚动阻止“touchstart” - React Warning non-passive event listener to a scroll-blocking 'touchstart' 警告:未知的事件处理程序属性“onHeaderClick”。 它会被忽略 - Warning: Unknown event handler property `onHeaderClick`. It will be ignored Android Fastclick问题 - Android fastclick issue 还是需要fastclick js吗? - Is fastclick js still needed? 无法初始化fastclick插件 - Unable to initialization of fastclick plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM