Message Waiting for the save button

2

Hello, gentlemen, I'm having trouble putting a message waiting for the user when he clicks the save button and waits for the server to return. I'm using Jquery Dialog and Partial View to load an html from the server inside a div. Anyone have 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>

   
    
asked by anonymous 11.02.2016 / 21:16

1 answer

1

I usually do 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.

    
12.02.2016 / 17:05