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

Commit 767a36d

Browse files
author
Gabriel Schulhof
committed
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.
1 parent 942ea92 commit 767a36d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

js/widgets/dialog.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ $.widget( "mobile.dialog", $.mobile.widget, {
6262
}
6363
});
6464

65+
$.extend( this, {
66+
_createComplete: false
67+
});
68+
6569
this._setCloseBtn( this.options.closeBtn );
6670
},
6771

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

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

0 commit comments

Comments
 (0)