Disable button for a short time after submission

pull/4/head
Sheng 2017-12-08 17:00:14 +08:00
parent c5c4f5707b
commit bd4182c9e0
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,12 @@
jQuery(function($){
var status = $('#status'),
btn = $('.btn-primary');
$('form#connect').submit(function(event) {
event.preventDefault();
status.text('');
btn.prop('disabled', true);
var form = $(this),
url = form.attr('action'),
@ -22,7 +28,10 @@ jQuery(function($){
function callback(msg) {
// console.log(msg);
if (msg.status) {
$('#status').text(msg.status);
status.text(msg.status);
setTimeout(function(){
btn.prop('disabled', false);
}, 3000);
return;
}

View File

@ -58,7 +58,7 @@
</div>
<div class="container">
<div id="status"></div>
<div id="status" style="color: red;"></div>
<div id="terminal"></div>
</div>