Find event executed

1

I made the following command to display a loading every time I submit a project form.

$("button[data-noPreload!='true'][type='submit']").click(openPreloading);
function openPreloading() {
    $("#icoCarregando").fadeIn();
}

I found this other code to help fix a crash to close the loading screen when there are errors in completing the form.

$("form").bind("invalid-form.validate", function () {
    $("#icoCarregando").hide();
});

So far everything was working fine, the problem I'm in need of help is when the user double-clicks to save a form whose error, the event created above does not seem to work, so Opening the Loading screen, when debugging I was able to identify that the functions created above are being executed, but this seems to be an extra event where loading the loading.

Is there any way to identify which event might be running and causing this problem? Or do you know how to circumvent this failure?

Thank you for your attention!

    
asked by anonymous 15.10.2018 / 14:28

1 answer

1

Are not you double-clicking the icon by double clicking?

Try changing your functions to this form:

var carregando = false;
$("button[data-noPreload!='true'][type='submit']").click(openPreloading);
function openPreloading() {
    if(carregando === false){
        $("#icoCarregando").fadeIn();
        carregando = true;
    }
}

$("form").bind("invalid-form.validate", function () {
    $("#icoCarregando").hide();
    carregando = false;
});
    
15.10.2018 / 14:43