Search results

Prevent toast close with mobile swipe in JavaScript (ES5) Toast control

27 Mar 2023 / 1 minute to read

You can prevent the toast close with mobile swipe action by setting beforeClose argument cancel value to true while argument type as a swipe. The following code shows how to prevent toast close with mobile swipe.

The following sample demonstrates preventing toast close with mobile swipe element displaying with custom code blocks.

Copied to clipboard

//Initialize Toast component
var toast = new ej.notifications.Toast({
    title: 'Matt sent you a friend request',
    content: 'You have a new friend request yet to accept',
    position: { X: "Center" },
    beforeClose: function (args) {
            if (args.type = "swipe") {
                args.cancel = true;
//Render initialized Toast component

document.getElementById('show_toast').onclick = function () {;