JQuery mobile:listview项上的点击事件也触发隐藏对象事件
动态生成的listview上的点击事件有问题。当我选择列表中的第一个项目时,操作是Fire,其中之一是取消隐藏附近的对象。问题是,未隐藏对象的点击事件也会在此时触发。我在编程方面没有丰富的背景,但我在软件测试方面有丰富的背景,因此您可以期待全面的复制步骤。:) 这是选择任何列表项时激发的事件:JQuery mobile:listview项上的点击事件也触发隐藏对象事件,jquery,events,listview,mobile,hidden,Jquery,Events,Listview,Mobile,Hidden,动态生成的listview上的点击事件有问题。当我选择列表中的第一个项目时,操作是Fire,其中之一是取消隐藏附近的对象。问题是,未隐藏对象的点击事件也会在此时触发。我在编程方面没有丰富的背景,但我在软件测试方面有丰富的背景,因此您可以期待全面的复制步骤。:) 这是选择任何列表项时激发的事件: //When a list item is selected $('#showItems').delegate('li', 'tap', function () { if ($('
//When a list item is selected
$('#showItems').delegate('li', 'tap', function () {
if ($('#showItems').hasClass("courses")){
courseNum = $(this).find('.course').text();
var profArr=new Array();
profArr[0]="";
profArr[1]="";
ajax_get_textbooks(courseNum, profArr[1], profArr[0]);
$('#showItems').removeClass('profs courses booksProf eitems').addClass('books');
}
else if ($('#showItems').hasClass("profs")){
prof = $(this).text();
profArr = prof.split(", ");
ajax_get_textbooks(courseNum, profArr[1], profArr[0]);
$('#showItems').removeClass('profs courses books eitems').addClass('booksProf');
}
$('#filters').removeClass('hidden'); // this is the object that gets acted upon incorrectly
});
当选择第一个列表元素时,也会触发此事件:
//When filter by professor/e-resources is selected
$('.filterBtn').bind('tap',function(event){
var filter = $(this).text();
filter = filter.toLowerCase();
if (filter.indexOf("prof") !== -1 ) {
ajax_filter_professor(courseNum);
$('#showItems').removeClass('books courses booksProf eitems').addClass('profs');
}
else {
ajax_filter_eresources(courseNum);
$('#showItems').removeClass('books profs booksProf courses').addClass('eitems');
}
$('#showItems').listview('refresh');
});
我想我可以通过将taphold事件附加到同一个函数来解决这个问题,但是下面的行不起作用:
$('#showItems').delegate('li', 'tap taphold', function () {
只有当我将相同的代码复制到taphold的新事件触发器中时,它才起作用
我希望能够以某种方式禁用$('.filterBtn').bind,直到第一个列表完成刷新,但我不知道如何做到这一点
以下是复制步骤
有人能帮我找出我做错了什么吗?也许你可以尝试使用JQM的vclick事件。 请参阅上JQM中支持的事件列表
如果不是Vclick,则可能适合其他对象。经过一个漫长的周末并找到e.stopPropagation()对象后解决。