繁体   English   中英

平板电脑应用中弹出多次打开

[英]Popup opening multiple times in tablet app

我正在创建表并将功能分配给on tap属性

我遇到的问题是,如果有3个表行,则提示将打开3次

谁能给我一个线索,让我知道如何解决这个问题?

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'
                    );
                }
            }
        }
    }
}

您需要执行以下代码$('#workList a').on('tap', editInstallQtyPrompt); 在该部分之外添加行,导致它多次发生。 因为您为添加的每个拖车注册了该事件,所以您有3个订阅者。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM