Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 9b0882c

Browse files
Gabriel Schulhofarschmitz
Gabriel Schulhof
authored andcommitted
Selectmenu: Update demo to no longer rely on deprecated page events
Re #7285 (comment) (cherry picked from commit 18d6b12)
1 parent 40b626e commit 9b0882c

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

demos/selectmenu-custom-filter/index.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,48 @@
3737
}
3838

3939
// Instantiate a filterable widget on the newly created listview and indicate that the
40-
// generated input is to be used for the filtering.
40+
// generated input form element is to be used for the filtering.
4141
list.filterable({
4242
input: input,
4343
children: "> li:not(:jqmData(placeholder='true'))"
4444
});
4545
})
4646

47-
// The custom select list may show up as either a popup or a dialog, depending how much
47+
// The custom select list may show up as either a popup or a dialog, depending on how much
4848
// vertical room there is on the screen. If it shows up as a dialog, then the form containing
4949
// the filter input field must be transferred to the dialog so that the user can continue to
5050
// use it for filtering list items.
51-
.on( "pagebeforeshow", "#filter-menu-dialog,#title-filter-menu-dialog", function( event ) {
52-
var dialog = $( event.target )
53-
listview = dialog.find( "ul" ),
54-
form = listview.jqmData( "filter-form" );
51+
.on( "pagecontainerbeforeshow", function( event, data ) {
52+
var listview, form,
53+
id = data.toPage && data.toPage.attr( "id" );
54+
55+
if ( !( id === "filter-menu-dialog" || id === "title-filter-menu-dialog" ) ) {
56+
return;
57+
}
58+
59+
listview = data.toPage.find( "ul" );
60+
form = listview.jqmData( "filter-form" );
5561

5662
// Attach a reference to the listview as a data item to the dialog, because during the
57-
// pagehide handler below the selectmenu widget will already have returned the listview
58-
// to the popup, so we won't be able to find it inside the dialog with a selector.
59-
dialog.jqmData( "listview", listview );
63+
// pagecontainerhide handler below the selectmenu widget will already have returned the
64+
// listview to the popup, so we won't be able to find it inside the dialog with a selector.
65+
data.toPage.jqmData( "listview", listview );
6066

6167
// Place the form before the listview in the dialog.
6268
listview.before( form );
6369
})
6470

6571
// After the dialog is closed, the form containing the filter input is returned to the popup.
66-
.on( "pagehide", "#filter-menu-dialog,#title-filter-menu-dialog", function( event ) {
67-
var listview = $( event.target ).jqmData( "listview" ),
68-
form = listview.jqmData( "filter-form" );
72+
.on( "pagecontainerhide", function( event, data ) {
73+
var listview, form,
74+
id = data.toPage && data.toPage.attr( "id" );
75+
76+
if ( !( id === "filter-menu-dialog" || id === "title-filter-menu-dialog" ) ) {
77+
return;
78+
}
79+
80+
listview = data.toPage.jqmData( "listview" ),
81+
form = listview.jqmData( "filter-form" );
6982

7083
// Put the form back in the popup. It goes ahead of the listview.
7184
listview.before( form );

0 commit comments

Comments
 (0)