3 Answers, 1 is accepted
0
Hello Matjaz,
By design, when a Window is opened or focused, its z-index is increased, so that the Window instance is guaranteed to be on top of all other instances.
Each time when you click on a button inside the first Window, the z-index of the first Window is increased, which ultimately causes it to be in a higher stacking context than the second Window. You can easily verify this if you check the browser's DOM inspector. When you close the third Window, the modal overlay is adjusted to be consistent with the modal Window with a highest stacking context, which is the first Window, so the second one naturally goes behind the modal overlay.
You can change the observed behavior by tweaking the z-index styles of the three Windows, according to your preferences:
Regards,
Dimo
Telerik
By design, when a Window is opened or focused, its z-index is increased, so that the Window instance is guaranteed to be on top of all other instances.
Each time when you click on a button inside the first Window, the z-index of the first Window is increased, which ultimately causes it to be in a higher stacking context than the second Window. You can easily verify this if you check the browser's DOM inspector. When you close the third Window, the modal overlay is adjusted to be consistent with the modal Window with a highest stacking context, which is the first Window, so the second one naturally goes behind the modal overlay.
You can change the observed behavior by tweaking the z-index styles of the three Windows, according to your preferences:
<!DOCTYPE html>
<
html
>
<
head
>
<
style
>html { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }</
style
>
<
title
>Window</
title
>
<
link
href
=
"http://cdn.kendostatic.com/2014.2.1008/styles/kendo.common.min.css"
rel
=
"stylesheet"
/>
<
link
href
=
"http://cdn.kendostatic.com/2014.2.1008/styles/kendo.default.min.css"
rel
=
"stylesheet"
/>
<
script
src
=
"http://cdn.kendostatic.com/2014.2.1008/js/jquery.min.js"
></
script
>
<
script
src
=
"http://cdn.kendostatic.com/2014.2.1008/js/kendo.web.min.js"
></
script
>
</
head
>
<
body
>
<
div
id
=
"example"
>
<
div
id
=
"window"
>
<
button
data-bind
=
"click: button1click"
>click first</
button
><
br
>
<
button
data-bind
=
"click: button2click"
>second button</
button
>
</
div
>
<
div
id
=
"window1"
>now click second button</
div
>
<
div
id
=
"window2"
>now close this window<
br
>window 1 will go behind modal overview</
div
>
</
div
>
<
script
>
var viewModel = kendo.observable({
button1click: function(e)
{
$('#window1').kendoWindow({position: {top: 200, left: 300}});
},
button2click: function(e)
{
$('#window2').kendoWindow({position: {top: 300, left: 400}});
var window0Wrapper = $("#window").data("kendoWindow").wrapper;
var window1Wrapper = $("#window1").data("kendoWindow").wrapper;
window0Wrapper.css("z-index", window1Wrapper.css("z-index") - 2);
},
});
kendo.bind($("body"), viewModel);
$('#window').kendoWindow({modal: true});
</
script
>
</
body
>
</
html
>
Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Oron
Top achievements
Rank 1
answered on 29 Mar 2016, 01:53 PM
Hey Dimo.
This unexpected behaviour happened to me to.
Is there any generic solution for this? Like a callback to help me deal with the zIndex after the modal window toFront's method was called?
I don't want to save a list of windows that my modal window opened.
Thanks in advanced.
0
Hello Oron,
It is possible to stop the propagation of the buttons' mousedown event. In this way the first Window widget will not be aware of the clicks and will not raise its z-index style.
Regards,
Dimo
Telerik
It is possible to stop the propagation of the buttons' mousedown event. In this way the first Window widget will not be aware of the clicks and will not raise its z-index style.
var
viewModel = kendo.observable({
button1click:
function
(e)
{
$(
'#window1'
).kendoWindow({position: {top: 200, left: 300}});
},
button2click:
function
(e)
{
$(
'#window2'
).kendoWindow({position: {top: 300, left: 400}});
},
});
kendo.bind($(
"body"
), viewModel);
$(
'#window'
).kendoWindow({modal:
true
});
function
buttonMouseDown(e) {
e.stopPropagation();
}
$(
'#window button'
).on(
"mousedown"
, buttonMouseDown);
Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!