I am currently working on creating a table and assigning a function to the onTap attribute.
The issue I'm facing is that when there are 3 table rows, the prompt opens 3 times.
Does anyone have any suggestions on how I can resolve 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'
);
}
}
}
}
}