I'm using jquery dialog to open a screen when the buttons clicked on the sidebar. Basically, when clicked buton, following codes run:
resizeDialog();
$("#dashboardContainer").dialog("open");
function resizeDialog() {
var relativeDiv, relativeHeight, relativeWidth, relativeMy;
if(myData.opening_type == 'full') {
relativeDiv = '#sContainer';
relativeWidth = '328';
relativeMy = 'left top';
} else {
relativeDiv = '#cContainer';
relativeMy = 'right top';
var mqDesktop2 = window.matchMedia( "(min-width : 1500px) and (max-width : 1750px)" );
var mqMobile = window.matchMedia( "(min-width:700px) and (max-width: 1500px)" );
if(mqMobile.matches) {
relativeWidth = '648';
} else if(mqDesktop2.matches) {
relativeWidth = '968';
} else {
relativeWidth = '1320';
};
}
relativeHeight = $(window).height() - ($("#cContainer").offset().top) - 20;
$("#myDialog")
.dialog( "option", "height", relativeHeight)
.dialog( "option", "width", relativeWidth)
.dialog( "option", "position", { my: relativeMy, at: "right top", of: relativeDiv, } );
}
But, when i frequently(one after another) click on the buttons, dialog opens with its previous size. When i add a timeout before opening dialog, it runs. But i don't want to add a timeout because dialog has to be opened immediately. Is there any other solutions that u can suggest?