Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3740

How to use SweetAlert2 in onPreClose event

$
0
0

This is my code below, as SweetAlert2 is async alert.

It is working to some extent, the editor close already before the preClose

editor.on('preClose', async function (e) {
                        // On close, check if the values have changed and ask for closing confirmation if they have
                        if (openVals !== JSON.stringify(Jobeditor_@(item.JobPrimaryID).get())) {
                            return   await editorConfirmAlert("You have unsaved changes. Are you sure you want to exit?", "Are you sure?")
                                    .then(function (result) {
                                        if (result.value) {
                                            return true
                                        } else {
                                            return false
                                        }
                                    });
                             //i am not using this confirm
                            //return confirm('You have unsaved changes. Are you sure you want to exit?');
                        }
                    })
                })

Viewing all articles
Browse latest Browse all 3740

Trending Articles