I have this code that opens jqueryui dialog windows on the page.
function Ventanica(url,titulo,ancho,alto) { //configuro la ventanica
if ($("#"+titulo).dialog('isOpen') === true) { $("#"+titulo).dialog("moveToTop") } else { //si la ventanuca ya esta abierta.
$("<div id='"+titulo+"' class='loaderchachi'><div id='loader'> </div></div>").dialog({ "title" : titulo , "width" : ancho , "height" : alto ,close : function(){ $(this).dialog("destroy"); $('.Li'+titulo).attr("onclick", "Ventanica('"+url+"','"+titulo+"','"+ancho+"','"+alto+"');"); $("#dock"+titulo).removeClass("active").addClass("cerrado"); } })
.dialogExtend({
"autoOpen": false, "closable" : true, "maximizable" : true, "minimizable" : true, "collapsable" : false, "dblclick" : "maximize", "titlebar" : "transparent", "minimizeLocation" : "right",
"icons" : {
"close" : "ui-icon-close",
"maximize" : "ui-icon-plus",
"minimize" : "ui-icon-minus",
"restore" : "ui-icon-bullet"
},
"load" : function(){
$("#loader").html('<div class="loader-container"><div class="spinchachi"></div></div>');
$("#"+titulo).load("/Paginas/"+url, function(response, status, xhr) { $("#loader").html('');
if ( status == "error" ) { var msg = "Ocurrio un error al cargar contenido remoto: "; $().toastmessage('showToast', { text : msg + xhr.status + " " + xhr.statusText , sticky : false, type : 'alert' }); }
$('.Li'+titulo).attr("onclick", '$("#'+titulo+'").dialog("moveToTop");');
$("#dock"+titulo).addClass("active");
});
},
"beforeMaximize" : function(evt) { EfectosmenuA(); $('#micromenusuario').css('top', 40); $('.Li'+titulo).attr("onclick", '$("#'+titulo+'").dialogExtend("restore");'); $("#dock"+titulo).removeClass("abierto").addClass("active"); },
"beforeRestore" : function(evt){ EfectosmenuC(); $('#micromenusuario').css('top', 10); $("#dock"+titulo).removeClass("abierto").addClass("active"); },
"beforeMinimize" : function(evt) { $("#dock"+titulo).removeClass("active").addClass("abierto"); },
});
} //cierro la condición de si es ventana nueva o primer plano
};
The fact is that I want to check if it is already open and if what I do is bring it to the forefront. in principle with:
if ($("#"+titulo).dialog('isOpen') === true) { $("#"+titulo).dialog("moveToTop") } else { //si la ventanuca ya esta abierta.
I check it and it works. but I need you to load the new content of the window. I think what loads content is inside the "Load"
"load" : function(){
$("#loader").html('<div class="loader-container"><div class="spinchachi"></div></div>');
$("#"+titulo).load("/Paginas/"+url, function(response, status, xhr) { $("#loader").html('');
if ( status == "error" ) { var msg = "Ocurrio un error al cargar contenido remoto: "; $().toastmessage('showToast', { text : msg + xhr.status + " " + xhr.statusText , sticky : false, type : 'alert' }); }
$('.Li'+titulo).attr("onclick", '$("#'+titulo+'").dialog("moveToTop");');
$("#dock"+titulo).addClass("active");
});
The fact is that the condition of if it is open is not very clear syntax and where to put the key lock to run instead of opening a new window, take it to the foreground and load the new content . at the moment I have placed it just before the closing of the function and it takes it to the foreground, but of course it does not load anything.
Where would I have to put that key lock so that instead of opening it will take it to the foreground and continue executing the load?
I tried to put it just before "dialogExtended" but it gives me a syntax error that says I'm missing one. but I do not know where: _ (
I have tried to see if the failure was because in $("#"+titulo).dialog("moveToTop")
before was closed with; but nothing, gives the same failure.
What can I be doing wrong?