Dhx.confirm button event click

Hello dev, how can I access the button click event for the confirm box. (Message control)

Imagine the script below.

     dhx.confirm({
      text: 'Are you sure you want to delete this entry?",
      buttons: ['No', 'Yes']
     });

Can how I assign an event if the user selected the β€˜YES’ button?.
On dhtmlxv5 they have api for this. If I remember it correctly it goes like below.

   dhtmlx.confirm({
     text: 'Are you sure you want to delete this entry?',
     callback: function(e){
        if(e) 
        {
            // the user press the "Yes/Okay" button
            setTimeout(function(){
              // confirmation code here.. proceed deletion of entry.
              // call some function here.
            }, 50);
        }
        return true;
     }
   });

How can I do that on this version 6?
Should I assign a function or click event on dhx_alert__confirm-aply via jquery/dom attach event?
Is there a way we can have an api similar to the v5? Much cleaner code.

 dhx.confirm({
    text: 'Are you sure you want to delete this entry?",
    buttons: ['No', 'Yes']
 }).then(answer => {
     if (answer) {
         //do something
     }
 })

where did you get that? I did see that on the documentation I downloaded. I also check the website and I cannot find that.

It is working, thank you. This is my script below.

 dhx.confirm({
    text: 'testing'
 }).then(function(e){
    console.dir(e); 
 });

Works like a charm. Thanks for the input. BTW where did you get that idea? I cannot find it on documentation they have.

https://docs.dhtmlx.com/suite/message__configuration.html

1 Like