簡體   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