sweetify-django icon indicating copy to clipboard operation
sweetify-django copied to clipboard

Handling event if ok button is clicked

Open ua4ever opened this issue 5 years ago • 2 comments

How to do that ?

ua4ever avatar Aug 19 '19 11:08 ua4ever

Hey @ua4ever,

sweetify is more or less for informational one-time messages only. There is currently no (prebuilt) way to handle clicks.

I'm happy to accept a PR, if you find a good solution for this in sweetify.

Atrox avatar Aug 23 '19 10:08 Atrox

I think that with sweetalerts2 you can do the following:

Swal.fire(
    ...
).then(result) {
    if (result.isConfirmed) {

    } else if (result.isDenied) {

    }
    ...
}

The parameters of result are the following as described in the official docs:

isConfirmed | The "Confirm" button was clicked, the value will contain the result
isDenied | The "Deny" button was clicked, the value will be false. Alternatively, if there's an input in a popup, you can use returnInputValueOnDeny: true to return the input's value.
isDismissed | The "Cancel" button was clicked, the dismiss will be Swal.DismissReason.cancel
value | The value from the popup, possible values:                        
 * true for simple confirmed dialogs             
 * false for denied popups             
 * any value for popups with inputs
dismiss | The dismissal reason, see the Handling Dismissals section for details

Maybe we could try to port this to sweetify?

PauMAVA avatar Apr 23 '21 20:04 PauMAVA