[英]Popup opening multiple times in tablet app
I am creating a table and assigning a function to the on tap attribute 我正在创建表并将功能分配给on tap属性
the problem i'm having is that if there are 3 table rows then the prompt is opening 3 times 我遇到的问题是,如果有3个表行,则提示将打开3次
Can anyone give me a clue as to how I might get round this ? 谁能给我一个线索,让我知道如何解决这个问题?
if(window.localStorage['role'] == 'fitter') {
//alert(window.localStorage['role']);
$('#workList tbody').append('<tr class="' + cssClass + '">'+
'<td>' + project.room_ref + '</td>'+
'<td>' + project.description + '</td>'+
'<td>' + project.total_qty + '</td>'+
'<td id="inst-qty" + i >' + '<a href="#" max="' + project.total_qty + '" id="proj-' + project.id + '" data-role="button" data-inline="true" class="ui-btn-right">' + instQty + '</a>' + '</td>'+
'<td>' + project.fitter_name + '</td>'+
'</tr>');
//$('#workList a').on('tap', editInstallQtyPrompt);
thisid = "proj-" + project.id ;
document.getElementById(thisid).onclick = editInstallQtyPrompt;
}
function onEditInstallQtyPrompt(results, projId, value, max) {
//alert('call onedit function');
if(results.buttonIndex == 1) { // OK
// validate input
//
var input = parseInt(results.input1);
if(isNaN(input)) {
navigator.notification.alert(
'Invalid input, number only',
function() {},
'Error'
);
} else {
if(input > max || input < value) {
navigator.notification.alert(
'Number must >= install qty, and < total qty',
function() {},
'Error'
);
} else {
if(isInt(input)) {
//console.log('new input: '+input);
updateProjectHistory(projId, input);
} else {
navigator.notification.alert(
'Integer only',
function() {},
'Error'
);
}
}
}
}
}
You need to do this code $('#workList a').on('tap', editInstallQtyPrompt);
您需要执行以下代码$('#workList a').on('tap', editInstallQtyPrompt);
out of the section you add rows in, cause it happens more than once. 在该部分之外添加行,导致它多次发生。 cause you register to the event for each tow you add, so you got 3 subscribers. 因为您为添加的每个拖车注册了该事件,所以您有3个订阅者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.