Skip to content

Commit 9ca8d93

Browse files
committed
Add the possibility to use '$( ".selector" ).dialog( "option", "zIndex", 3999 );', as noted in the docs on http://jqueryui.com/demos/dialog/ .
1 parent 70687f7 commit 9ca8d93

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/unit/dialog/dialog_options.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,4 +441,31 @@ test("width", function() {
441441
el.remove();
442442
});
443443

444+
test("zIndex", function() {
445+
expect(6);
446+
447+
el = $('<div></div>').dialog( { autoOpen: false } );
448+
equals(dlg().css( 'zIndex' ), 1000, "default zIndex");
449+
el.dialog("open");
450+
equals(dlg().css( 'zIndex' ), $.ui.dialog.maxZ, "default zIndex");
451+
el.remove();
452+
453+
el = $('<div></div>').dialog();
454+
equals(dlg().css( 'zIndex' ), $.ui.dialog.maxZ, "default zIndex");
455+
el.remove();
456+
457+
// The z-index will always be 1 higher than requested if 'moveToTop' gets called, such as when 'autoOpen' is true.
458+
el = $('<div></div>').dialog({zIndex: 2932 });
459+
equals(dlg().css('zIndex'), 2932 + 1, "explicit zIndex");
460+
el.dialog('option', 'zIndex', 1748);
461+
equals(dlg().css('zIndex'), 1748, 'explicit zIndex after init');
462+
el.remove();
463+
464+
// At the moment, an explicit zIndex option lower than $.ui.dialog.maxZ will be ignored since 'open' calls
465+
// 'moveToTop'. Is this the desired behavior?
466+
el = $('<div></div>').dialog({zIndex: 1584 });
467+
equals(dlg().css('zIndex'), $.ui.dialog.maxZ, "explicit zIndex, lower than $.ui.dialog.maxZ, is ignored");
468+
el.remove();
469+
});
470+
444471
})(jQuery);

ui/jquery.ui.dialog.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ $.widget("ui.dialog", {
595595
$( ".ui-dialog-title", self.uiDialogTitlebar )
596596
.html( "" + ( value || "&#160;" ) );
597597
break;
598+
case "zIndex":
599+
uiDialog.css({ zIndex: value });
600+
break;
598601
}
599602

600603
this._super( "_setOption", key, value );

0 commit comments

Comments
 (0)