Read HTML inside a Sweetalert plugin confirmButtonText

Asked

Viewed 98 times

0

I have an action originated by the plugin Sweetalert that needs a button with text well extended because it is a very sensitive option and can lead to errors.

 swal({
                            title: data['title'],
                            text: data['msg'],
                            type: 'warning',
                            showConfirmButton: true,
                            showCancelButton: true,
                            closeOnConfirm: true,
                            confirmButtonText: 'Confirmar exclusão (Essa ação não é recomendada \n, <small>Deletar este colaborador pode acarretar em inconsistencias nos dados anteriores, você pode torna-lo inativo, ou registrar um desligamento de funcionário.</small>.)',
                            cancelButtonText: 'Cancelar e voltar'
                        },
                                function (isConfirm) {
                                    alert();
                                });

My question is basically:

How to make the plugin read past HTML to 'confirmButtonText' ? Or you can’t do it ?

  • It is not common for a button to have such a long text. Have you ever thought to put on the button only the text "Confirm Deletion" and display the warning about the action in the body of the alert?

  • It is not possible, because in the body I already have a text describing some things, this is a very critical function of the system, I need the detailed description.

  • 1

    See Sweetalert2, added HTML support on the buttons: https://limonte.github.io/sweetalert2/

2 answers

0

I believe that’s what you want, the tag <small> will not work because sweetAlert does not support html.

swal("Mensagem", {
    icon: "warning",
  buttons: {
    btn1: "Confirmar exclusão (Essa ação não é recomendada \n, <small>Deletar este colaborador pode acarretar em inconsistencias nos dados anteriores, você pode torna-lo inativo, ou registrar um desligamento de funcionário.</small>.",
    btn2: "Cancelar"
  },
})
.then((value) => {
  switch (value) {

    case "btn1":
      return true;
      break;

    case "btn2":
      return false;
      break;

    default:
      swal("404");
  }
});

0


The answer was @Renato Diniz' comment on the question.

I changed it to Sweetalert2, problem solved.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.