问题
I have a filter function implemented on "panel" in jQuery Mobile:
- I call filter by clicking on any button, the panel slides from left and there are filter options to set up current filter.
- If multiple select box contains a lot of options, it shows on a black background covering the whole page and it closes the panel.
I need to reopen the panel with filter after this dialog of multi-select is closed...
I am using this:
$('#filter select').bind('change',function(){
$('#filter').panel('open');
});
This is OK if the user does any change in opened dialog (select)...
But what if he just closes this dialog using the X-button without any change? Dialog disappears, but panel is not reopened.
Thank you very much for any help.
回答1:
jQuery Mobile custom selectmenu are either converted into popup or a dialog depending on screen size and options length.
When the selectmenu is dialog, it navigates to a new dialog-page. In that case, you can listen to pagecontainer events to retrieve previous prevPage and next page toPage.
If previous page is a dialog/selectmenu, open panel in next page.
$(document).on("pagecontainershow", function (e, data) {
var previousPage = data.prevPage,
nextPage = data.toPage;
if (previousPage.hasClass("ui-selectmenu")) { /* or ui-dialog */
$(".ui-panel", nextPage).panel("open");
}
});
Demo
来源:https://stackoverflow.com/questions/26670122/jquery-mobile-select-onclose-event