如果手動設置類,你可以做的最好的,但爲了將來JQM改進也許你可以現在做兩個:
我只是提高Gajotres的答案,並導致jsFiddle
var panel = $("#rightpanel"),
DEFAULT = {
POSITION: {
left: {type: "left"},
right: {type: "right"}
},
DISPLAY: {
overlay: { type: "overlay" , className: "ui-panel-display-overlay"},
reveal: { type: "reveal" , className: "ui-panel-display-reveal"},
push: { type: "push" , className: "ui-panel-display-push"}
}
},
lastState = {
display: DEFAULT.DISPLAY.push,
position: DEFAULT.POSITION.left
};
function options (key, value) {
return panel.panel("option", key, value);
}
function position (pos) {
// { left | right }
if (
DEFAULT.POSITION[pos] &&
DEFAULT.POSITION[pos].type !== lastState.position.type
){
panel.panel("close");
lastState.position = DEFAULT.POSITION[pos]
panel
.toggleClass("ui-panel-position-left ui-panel-position-right");
return options("position", pos);
}
}
function display (disp) {
// { overlay | reveal | push }
if (
DEFAULT.DISPLAY[disp] &&
DEFAULT.DISPLAY[disp].type !== lastState.display.type
) {
panel.panel("close");
lastState.display = DEFAULT.DISPLAY[disp]
panel
.removeClass("ui-panel-display-reveal ui-panel-display-overlay ui-panel-display-push")
.addClass(display.className);
return options("display", disp);
}
}
$(document).on('pagebeforeshow', '#index', function(){
$(document).on('click', '#openpanel', function() {
position("right");
panel.panel("open")
});
});
打開面板和內聯改變其選擇,是行不通的。它也出現在彈出窗口中。檢查這個問題,它與你的問題類似。 [問題](http://stackoverflow.com/questions/15435934/jquery-mobile-popup-dialog-disallow-on-options-doesnt-work) – Omar 2013-03-15 21:43:26