I am using a JQ dialog to replace the native js confirm() function. To use it as a central function I've put it into a function.
var dialogID = "dialog_" + createUUID();
var width = 300;
var height = 150;
var url = "";
var formObj = "";
function jqConfirm(dialogID,title,txt,width,height,url,formObj) {
var dialog = $("#" + dialogID);
// generate the HTML
if (!$("#" + dialogID).length) {
dialog = $('<div id="' + dialogID + '" style="display:hidden;" class="loading"></div>').appendTo('body');
}
dialog.dialog({
bgiframe: true,
autoOpen: false,
width: width,
height: height,
minWidth:100,
minHeight:100,
maxWidth:980,
maxHeight:700,
modal: true,
dialogClass: 'dialogWithDropShadow',
resizable:false,
draggable:false,
show:'fade',
hide:'fade',
title: title,
buttons: [
{
text: "OK",
"class": 'mscbutton',
click: function() {
if (formObj.length) {
$(formObj).submit();
} else if (url.length) {
document.location.href = url;
}
$(this).dialog('close');
}
},
{
text: "Cancel",
"class": 'mscbutton',
click: function() {
$(this).dialog('close');
return false;
}
}
],
});
// fill the dialog
$(dialog).html(txt);
dialog.dialog('open');
$(dialog).removeClass('loading');
}
I call the function from within other JS files. A js confirm() I'd use like this:
if (confirm('confirm me')) doThis();
But this way won't work with my function because all I get is an "undefined".
if (jqConfirm(paramstring...)) doThis();
The dialog opens and works just fine but seems to return nothing. I know I am doing something wrong. But what?
Thank u all Greetings