DialogBOX: Handle true/false and hide it

I am using Dialog Box. 

IF the user clicks on the OK Button then I am calling the function named okClickTest(). 


<ejs-button id="dialogBtn" content="SAVE TO DB"></ejs-button>

document.getElementById("dialogBtn").onclick = function () {
    ej.popups.DialogUtility.confirm({
            title: ' Confirmation Dialog',          
            content:CheckToUploadFile(),     
            okButton: {
                text: 'OK', click: function () {
                    okClickTest();
                    this.hide();
                } },
            cancelButton: { text: 'Cancel', click: function () {
                cancelClickTest();
                    this.hide();
                } },
            showCloseIcon: true,
            closeOnEscape: true,
            animationSettings: { effect: 'Zoom' }
        });
    };

Here is my function 

function okClickTest() {
// Coding and Check OTHER FILEDS are NULL OR NOT (SET variable "a", TRUE OR FALSE...)
  if (a == false){
 //Cancle further operation
//Return false and HIDE THE DIALOG BOX
}
else{
// Continue my AJAX CALLED And Call my Controller Event 
}
}

HERE IS MY QUESTION

How can I, 

1) return TRUE OR FALSE from okClickTest(). 

2) hide the DIALOG BOX and cancel my further operation if, the "IF" condition is executed in my case?


1 Reply 1 reply marked as answer

BS Buvana Sathasivam Syncfusion Team April 4, 2022 01:55 PM UTC


Hi Harshida,


Greetings from Syncfusion support.


You can just return the true or false from okClickTest() method based on if condition and stored in the variable name. Please find the below code and attached sample for your reference.


okButton: {

   text: 'OK', click: function () {

   var isTrue = okClickTest();   // okClickTest() method return the boolean and stored into variable name             

   if (!isTrue) { // Checked the return condition and hide the dialog if variable returned as false

      this.hide();  // Hide the dialog

  }

}  },

 

……………

function okClickTest() {

        var a = true;

        if (a == false) {

           ……..

          return false    // You can return as false (It will hide the dialog)

        }

        else {

            // Continue your AJAX CALLED

            return true    // You can return as true (It will not hide the dialog)

        }

    }


Please check the above code and sample and let us know if your problem has been resolved.


Regards,

Buvana S


Attachment: Core_(6)_4c929c26.zip

Marked as answer
Loader.
Up arrow icon