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

Commit 77143ac

Browse files
author
Gabriel Schulhof
committed
Custom select: Moving binding that causes the dialog page to be destroyed into the widget prototype and calling it _handleMenuPageHide().
1 parent 5c99158 commit 77143ac

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

js/widgets/forms/select.custom.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
104104
}
105105
},
106106

107+
_handleMenuPageHide: function() {
108+
// TODO centralize page removal binding / handling in the page plugin.
109+
// Suggestion from @jblas to do refcounting
110+
//
111+
// TODO extremely confusing dependency on the open method where the pagehide.remove
112+
// bindings are stripped to prevent the parent page from disappearing. The way
113+
// we're keeping pages in the DOM right now sucks
114+
//
115+
// rebind the page remove that was unbound in the open function
116+
// to allow for the parent page removal from actions other than the use
117+
// of a dialog sized custom select
118+
//
119+
// doing this here provides for the back button on the custom select dialog
120+
$.mobile._bindPageRemove.call( this.thisPage );
121+
},
122+
107123
build: function() {
108124
var selectId, prefix, popupId, dialogId, label, thisPage, isMultiple, menuId, themeAttr, overlayThemeAttr,
109125
dividerThemeAttr, menuPage, listbox, list, header, headerTitle, menuPageContent, menuPageClose, headerClose, self,
@@ -229,21 +245,7 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
229245

230246
// button refocus ensures proper height calculation
231247
// by removing the inline style and ensuring page inclusion
232-
this.menuPage.bind( "pagehide", function() {
233-
// TODO centralize page removal binding / handling in the page plugin.
234-
// Suggestion from @jblas to do refcounting
235-
//
236-
// TODO extremely confusing dependency on the open method where the pagehide.remove
237-
// bindings are stripped to prevent the parent page from disappearing. The way
238-
// we're keeping pages in the DOM right now sucks
239-
//
240-
// rebind the page remove that was unbound in the open function
241-
// to allow for the parent page removal from actions other than the use
242-
// of a dialog sized custom select
243-
//
244-
// doing this here provides for the back button on the custom select dialog
245-
$.mobile._bindPageRemove.call( self.thisPage );
246-
});
248+
this._on( this.menuPage, { pagehide: "_handleMenuPageHide" } );
247249

248250
// Events on the popup
249251
this.listbox.bind( "popupafterclose", function() {

0 commit comments

Comments
 (0)