【问题标题】:jquery popup closes immediately after opening in cordova iOS 9jquery弹出窗口在cordova iOS 9中打开后立即关闭
【发布时间】:2015-10-16 03:16:50
【问题描述】:

我有这个在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 中都能正常工作。但在科尔多瓦 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");                   
    }
}

【问题讨论】:

    标签: jquery cordova popup ios9


    【解决方案1】:

    将 data-history="false" 放在弹出的 div 上

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 2015-01-23
      • 1970-01-01
      • 2013-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多