|
37 | 37 | }
|
38 | 38 |
|
39 | 39 | // 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. |
41 | 41 | list.filterable({
|
42 | 42 | input: input,
|
43 | 43 | children: "> li:not(:jqmData(placeholder='true'))"
|
44 | 44 | });
|
45 | 45 | })
|
46 | 46 |
|
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 |
48 | 48 | // vertical room there is on the screen. If it shows up as a dialog, then the form containing
|
49 | 49 | // the filter input field must be transferred to the dialog so that the user can continue to
|
50 | 50 | // 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" ); |
55 | 61 |
|
56 | 62 | // 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 ); |
60 | 66 |
|
61 | 67 | // Place the form before the listview in the dialog.
|
62 | 68 | listview.before( form );
|
63 | 69 | })
|
64 | 70 |
|
65 | 71 | // 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" ); |
69 | 82 |
|
70 | 83 | // Put the form back in the popup. It goes ahead of the listview.
|
71 | 84 | listview.before( form );
|
|
0 commit comments