【发布时间】: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");
}
}
【问题讨论】: