0
I have a screen to add members and when the member is added the user already views in a table below (AJAX).
When users are clicking on the add button the request may take, depending on "N" factors, and when it takes, users keep clicking on the add button, which results in multiple inserts and multiple "identical" records in the table.
I just want to disable the button while the request is completed and the table updated, but I don’t know much about JS.
My code:
$('form#{$model->formname()}').on('beforeSubmit', function(e)
{
var \$form = $(this);
$.post(
\$form.attr("action"),
\$form.serialize(),
).done(function(result){
$.pjax.reload({container:'#membros'});
$(\$form).trigger("reset");
}).fail(function(){
$(\$form).trigger("reset");
$.pjax.reload({container:'#membros'});
});
return false;
});
It worked out here. Vlw even :)
– Guilherme Luis