在cordova iOS 9中打开后,jquery弹出窗口立即关闭

时间:2015-10-16 03:16:50

标签: jquery cordova popup ios9

我有一个在cordova函数中创建的弹出窗口。

var problem_list2 = new Array();
function addSymptom(symptom){
    $.ajaxSetup({   async: false});
    //$.mobile.loading('show');
    if($.inArray(symptom, problem_list2)===-1){ 
        problem_list2.push(symptom);
        //var lis = problem_list2;
        var $popUp = $("<div/>").popup({
            dismissible : true,
            theme : "a",
            overlayTheme : "a",
            transition : "slide"
        }).bind("popupafterclose", function() {
            $(this).remove();
        });
        $("<h2/>", {
            text : "Problem List"
        }).appendTo($popUp);
        for(var i=0;i<problem_list2.length;i++){
            $("<h4/>", {          
                text : problem_list2[i]
           }).appendTo($popUp);
        }
        $('<input type="button" data-iconpos="right" data-icon="plus" value="Add More Symptoms" onclick="closer()">').appendTo($popUp);
        $('<input type="button" data-iconpos="right" data-icon="check" value="Diagnose" onclick="diagnose()">').appendTo($popUp);          
        $popUp.popup("open").trigger("create");                   
    }
}

按下关闭按钮时,此功能会关闭弹出窗口:

function closer(){    
    $('.ui-popup').popup('close'); 
}  

它适用于任何网络浏览器和cordova android。但在cordova iOS 9中,弹出窗口在第一次打开时会立即关闭。在第一次保持打开之后,此行为仅在第一次打开时发生。我尝试以这种方式添加data-history ='false':

var problem_list2 = new Array();
function addSymptom(symptom){
    $.ajaxSetup({   async: false});
    //$.mobile.loading('show');
    if($.inArray(symptom, problem_list2)===-1){ 
        problem_list2.push(symptom);
        //var lis = problem_list2;
        var $popUp = $("<div data-history='false' />").popup({
            dismissible : true,
            theme : "a",
            overlayTheme : "a",
            transition : "slide"
        }).bind("popupafterclose", function() {
            $(this).remove();
        });
        $("<h2/>", {
            text : "Problem List"
        }).appendTo($popUp);
        for(var i=0;i<problem_list2.length;i++){
            $("<h4/>", {          
                text : problem_list2[i]
           }).appendTo($popUp);
        }
        $('<input type="button" data-iconpos="right" data-icon="plus" value="Add More Symptoms" onclick="closer()">').appendTo($popUp);
        $('<input type="button" data-iconpos="right" data-icon="check" value="Diagnose" onclick="diagnose()">').appendTo($popUp);          
        $popUp.popup("open").trigger("create");                   
    }
}

这样:

var problem_list2 = new Array();
function addSymptom(symptom){
    $.ajaxSetup({   async: false});
    //$.mobile.loading('show');
    if($.inArray(symptom, problem_list2)===-1){ 
        problem_list2.push(symptom);
        //var lis = problem_list2;
        var $popUp = $("<div/>").popup({
            dismissible : true,
            datahistory : 'false',
            theme : "a",
            overlayTheme : "a",
            transition : "slide"
        }).bind("popupafterclose", function() {
            $(this).remove();
        });
        $("<h2/>", {
            text : "Problem List"
        }).appendTo($popUp);
        for(var i=0;i<problem_list2.length;i++){
            $("<h4/>", {          
                text : problem_list2[i]
           }).appendTo($popUp);
        }
        $('<input type="button" data-iconpos="right" data-icon="plus" value="Add More Symptoms" onclick="closer()">').appendTo($popUp);
        $('<input type="button" data-iconpos="right" data-icon="check" value="Diagnose" onclick="diagnose()">').appendTo($popUp);          
        $popUp.popup("open").trigger("create");                   
    }
}

1 个答案:

答案 0 :(得分:0)

在你的弹出式div上放置data-history =“false”