jquery mobile select onclose event

独自空忆成欢 提交于 2019-12-24 06:38:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!