Permalink
Browse files

Dialog: Make sure close button inherits header theme.

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...
1 parent 942ea92 commit 767a36df690f85328226bd614d6df86e4b4cabdc @gabrielschulhof gabrielschulhof committed Nov 22, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 js/widgets/dialog.js
@@ -62,6 +62,10 @@ $.widget( "mobile.dialog", $.mobile.widget, {
}
});
+ $.extend( this, {
+ _createComplete: false
+ });
+
this._setCloseBtn( this.options.closeBtn );
},
@@ -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

0 comments on commit 767a36d

Please sign in to comment.