[英]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.