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

Commit

Permalink
Dialog: Make sure close button inherits header theme.
Browse files Browse the repository at this point in the history
When the button is added to the dialog during _create(), the header is not yet enhanced, so getInheritedTheme() works incorrectly. OTOH, since the header is not enhanced, the button need not be enhanced during create either, since it will be enhanced later when the header is itself enhanced. The button only needs to be enhanced when the option is being set on-the-fly.
  • Loading branch information
Gabriel Schulhof committed Nov 22, 2012
1 parent 942ea92 commit 767a36d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions js/widgets/dialog.js
Expand Up @@ -62,6 +62,10 @@ $.widget( "mobile.dialog", $.mobile.widget, {
}
});

$.extend( this, {
_createComplete: false
});

this._setCloseBtn( this.options.closeBtn );
},

Expand All @@ -76,10 +80,11 @@ $.widget( "mobile.dialog", $.mobile.widget, {
// Sanitize value
location = ( value === "left" ? "left" : "right" );
btn = $( "<a href='#' class='ui-btn-" + location + "' data-" + $.mobile.ns + "icon='delete' data-" + $.mobile.ns + "iconpos='notext'>"+ this.options.closeBtnText + "</a>" );
if ( $.fn.buttonMarkup ) {
this.element.children().find( ":jqmData(role='header')" ).prepend( btn );
if ( this._createComplete && $.fn.buttonMarkup ) {
btn.buttonMarkup();
}
this.element.children().find( ":jqmData(role='header')" ).prepend( btn );
this._createComplete = true;

// this must be an anonymous function so that select menu dialogs can replace
// the close method. This is a change from previously just defining data-rel=back
Expand Down

0 comments on commit 767a36d

Please sign in to comment.