dhtmlx.confirm

Hi,

This is my problem:

I’d’like to use dhtmlx.confirm instead the native confirm because more flexible in configuration and also more customizable, but i don’t understand what’ s wrong with it.

This is my code:

contactForm.attachEvent(“onBeforeDataLoad”, function(id ,values) {
if(cambio==1) {
dhtmlx.confirm ({
type: “confirm-warning”,
title: “Avviso”.
text: “Modifiche non salvate ! Uscire senza salvare?”,
ok: “SI”
cancel: “NO”,
callback function(result) {
if (result == true) {
alert (“premuto SI”);
return true;
}
else {
alert (“premuto NO”);
return false;
};
}
});
}
else {
alert("OK no modifiche);
return true;
};
});

In this way when the variable cambio is 1 the event never exit with true, even if the alert (“premuto SI”) has shown

Why ?
If i use the native confirm in the same way all runs correctly. Probably your confirm is different from native, but how can i modify my code to use yours ???

Many many thanks

callbacks of dhtmlx.confirm fire in async. mode, it will not block execution, so code of onBeforeDataLoad will finish executing and will return undefined value, without vaiting for confirm callback.

If you need to use sync confirm - the native window.confirm is the only solution ( it is not possible to block code execution from the javascript )

Thank you Stanislav.

One question again.

I Think that native alert was made to be used in a modal (or sync) way, why your message and confirm is not ?

In your opinion how have i to modify the code of my previous post to use in a async way ?

Thanks again.

There is no way in javascript code to block code execution.
The native alert and confirm are special cases - the same can’t be achieved from js code.
( callback approach it is the only possible solution for non-native messages )

Thaks Stanislav but why don’t you tell me that the modalbox exist ?

It’s exactly what i need and it seems to run in the modal way blocking code waiting for the response. Can you confirm that ?

The problems seem never end so i have another question ! i’ve just posted it and this is the link to the post.

http://forum.dhtmlx.com/viewtopic.php?f=2&t=32673

Many thanks again for help:

The modal box doesn’t block script execution, as it impossible do from raw js code ( that is not specific of dhtmlx library, but browser level limitation )