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

Commit

Permalink
Custom select: Moving binding that causes the dialog page to be destr…
Browse files Browse the repository at this point in the history
…oyed into the widget prototype and calling it _handleMenuPageHide().
  • Loading branch information
Gabriel Schulhof committed Jun 18, 2013
1 parent 5c99158 commit 77143ac
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions js/widgets/forms/select.custom.js
Expand Up @@ -104,6 +104,22 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
}
},

_handleMenuPageHide: function() {
// TODO centralize page removal binding / handling in the page plugin.
// Suggestion from @jblas to do refcounting
//
// TODO extremely confusing dependency on the open method where the pagehide.remove
// bindings are stripped to prevent the parent page from disappearing. The way
// we're keeping pages in the DOM right now sucks
//
// rebind the page remove that was unbound in the open function
// to allow for the parent page removal from actions other than the use
// of a dialog sized custom select
//
// doing this here provides for the back button on the custom select dialog
$.mobile._bindPageRemove.call( this.thisPage );
},

build: function() {
var selectId, prefix, popupId, dialogId, label, thisPage, isMultiple, menuId, themeAttr, overlayThemeAttr,
dividerThemeAttr, menuPage, listbox, list, header, headerTitle, menuPageContent, menuPageClose, headerClose, self,
Expand Down Expand Up @@ -229,21 +245,7 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, {

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

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

0 comments on commit 77143ac

Please sign in to comment.