Fix #13
This commit is contained in:
parent
d5e547a555
commit
b44bdf597f
1 changed files with 20 additions and 19 deletions
|
@ -1,9 +1,9 @@
|
|||
ready = function() {
|
||||
form = $("#new_transaction")
|
||||
submit_button = $(form).find("input[type=submit]")
|
||||
errors = $("#transaction_errors")
|
||||
panel_ul = $(errors).find(".panel-body ul")
|
||||
flash_success = $("#transaction_success")
|
||||
form = $("#new_transaction");
|
||||
submit_button = $(form).find("input[type=submit]");
|
||||
errors = $("#transaction_errors");
|
||||
panel_ul = $(errors).find(".panel-body ul");
|
||||
flash_success = $("#transaction_success");
|
||||
|
||||
var table = $('#transactions').DataTable({
|
||||
processing: true,
|
||||
|
@ -71,30 +71,31 @@ ready = function() {
|
|||
filters_body.hide();
|
||||
|
||||
$(form).on("ajax:before", function(xhr, settings) {
|
||||
$(flash_success).addClass("hidden")
|
||||
$(submit_button).val("Processing")
|
||||
$(flash_success).addClass("hidden");
|
||||
$(submit_button).val("Processing");
|
||||
$(submit_button).attr('disabled', 'disabled');
|
||||
}).on("ajax:success", function(data, status, xhr) {
|
||||
$(flash_success).removeClass("hidden")
|
||||
$(errors).addClass("hidden")
|
||||
$(form)[0].reset()
|
||||
$(flash_success).removeClass("hidden");
|
||||
$(errors).addClass("hidden");
|
||||
$(form)[0].reset();
|
||||
$('#transaction_creditor').select2('data', null);
|
||||
}).on("ajax:error", function(xhr, status, error) {
|
||||
$(errors).removeClass("hidden")
|
||||
$(panel_ul).empty()
|
||||
$(errors).removeClass("hidden");
|
||||
$(panel_ul).empty();
|
||||
$.each(JSON.parse(status.responseText), function(index, val) {
|
||||
$(panel_ul).append("<li>" + val + "</li>")
|
||||
})
|
||||
$(panel_ul).append("<li>" + val + "</li>");
|
||||
});
|
||||
}).on("ajax:complete", function(xhr, status) {
|
||||
$(submit_button).val("Send it")
|
||||
$(submit_button).val("Send it");
|
||||
$(submit_button).attr('disabled', false);
|
||||
table.ajax.reload();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$.ajaxSetup({
|
||||
dataType: 'text'
|
||||
})
|
||||
});
|
||||
|
||||
$(document).ready(ready)
|
||||
$(document).on('page:load', ready)
|
||||
$(document).ready(ready);
|
||||
$(document).on('page:load', ready);
|
||||
|
|
Loading…
Reference in a new issue