Message de Aguarde when clicking the save button

Asked

Viewed 603 times

2

Hello, gentlemen I’m having trouble putting a message waiting for the user when they click save button and stay waiting for the return of the server. I am using Jquery Dialog and Partial View to load an html from the server into a div. Someone has an idea?

 $("#NovoDialog").html("").dialog("option", "title", "Novo").load("/Teste/Create", function () { $("#NovoDialog").dialog("open"); });

  $("#NovoDialog").dialog({
                autoOpen: false, width: 520, height: 550, modal: true,
                buttons: {
                    "Salvar": function (evt) {
                        var buttonDomElement = evt.target;
                        $(buttonDomElement).attr('disabled', true);
                        if ($("#FormCadastro").validate().form()) {
                            $.post("/RegistroAcaoCorretiva/Save",
                                $("#FormCadastro").serialize(),
                                function (data) {
                                    if (data.success) {
      
                                        $("#NovoDialog").dialog("close");
                                        location.reload();
                                      
                                    } else {        
                                        $("#NovoDialog").html(data);
                                           $.validator.unobtrusive.parse($("#NovoDialog"));
                                    }
                                });
                        } else {
                            $(buttonDomElement).attr('disabled', false);
                        }
                    },
                    Cancelar: function () { $(this).dialog("close"); }
                }
            });
  <div id="progressbar">
    <h2>TESTE</h2>
      <div id="NovoDialog" title="" class="Hidden"></div>
    </div>

   

1 answer

1


I usually do like this:

    $('form').on('submit', function () {
        $('button[type="submit"]').prop('disabled', true).text("Aguarde...");
        setTimeout(function () {
            $('button[type="submit"]').prop('disabled', false).text("Salvar");
        }, 10000); // Aqui você define quantos milissegundos a tela deve aguardar.
    });

This is for the save button, but the logic for a modal message, for example, is the same.

  • 1

    Thanks Gypsy that way works.

Browser other questions tagged

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