问题
jquerymobile 1.30 + jquery 1.91
//dismissible doesn't apply
$("#popupDialogCategoriesButton").click(function (e) {
$("#popupDialogCategories").popup("open", { dismissible: false })
});
//dismissible does apply , set it after open
$("#popupDialogCategoriesButton").click(function (e) {
$("#popupDialogCategories").popup('open');
$("#popupDialogCategories").popup("option", "dismissible", false);
});
回答1:
Update
In order to open the popup and change the value of dismissible at the same time, add data-dismissible="" with no value/blank to the popup markup, then you can change it to either true or false.
Markup
<div data-role="popup" id="popupBasic" data-dismissible="">
<p>To close me, hit the button below.
<p> <a href="#" data-role="button" data-rel="back">close</a>
</div>
JQM
$(document).on('click', '#openpopup', function () {
$('#popupBasic').popup('open', { dismissible: false });
});
You have two options:
1) To define the value of data-dismissible in the popup markup.
Markup
<div data-role="popup" id="popupBasic" data-dismissible="false">
<p>To close me, hit the button below.<p>
<a href="#" data-role="button" data-rel="back">close</a>
</div>
<a href="#" data-role="button" id="openpopup">click me</a> // open it
JQM
$(document).on('click', '#openpopup', function() {
$('#popupBasic').popup("open");
});
2) Change dismissible value before/after opening it.
Markup
<div data-role="popup" id="popupBasic">
<p>To close me, hit the button below.<p>
<a href="#" data-role="button" data-rel="back">close</a>
</div>
<a href="#" data-role="button" id="openpopup">click me</a> // open it
JQM
$(document).on('click', '#openpopup', function() {
$('#popupBasic').popup("open");
$('#popupBasic').popup({ dismissible: false });
});
Live example - updated
回答2:
I got the same problem and my solution is to list all the options down below
$("#popupDialog").popup({history: false});
$("#popupDialog").popup({corners: false});
$("#popupDialog").popup({shadow: false});
$("#popupDialog").popup("open");
It's not good looking but working well.
来源:https://stackoverflow.com/questions/15435934/jquery-mobile-popup-dialog-dismissible-on-options-doesnt-work