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() {
|
ready = function() {
|
||||||
form = $("#new_transaction")
|
form = $("#new_transaction");
|
||||||
submit_button = $(form).find("input[type=submit]")
|
submit_button = $(form).find("input[type=submit]");
|
||||||
errors = $("#transaction_errors")
|
errors = $("#transaction_errors");
|
||||||
panel_ul = $(errors).find(".panel-body ul")
|
panel_ul = $(errors).find(".panel-body ul");
|
||||||
flash_success = $("#transaction_success")
|
flash_success = $("#transaction_success");
|
||||||
|
|
||||||
var table = $('#transactions').DataTable({
|
var table = $('#transactions').DataTable({
|
||||||
processing: true,
|
processing: true,
|
||||||
|
@ -71,30 +71,31 @@ ready = function() {
|
||||||
filters_body.hide();
|
filters_body.hide();
|
||||||
|
|
||||||
$(form).on("ajax:before", function(xhr, settings) {
|
$(form).on("ajax:before", function(xhr, settings) {
|
||||||
$(flash_success).addClass("hidden")
|
$(flash_success).addClass("hidden");
|
||||||
$(submit_button).val("Processing")
|
$(submit_button).val("Processing");
|
||||||
$(submit_button).attr('disabled', 'disabled');
|
$(submit_button).attr('disabled', 'disabled');
|
||||||
}).on("ajax:success", function(data, status, xhr) {
|
}).on("ajax:success", function(data, status, xhr) {
|
||||||
$(flash_success).removeClass("hidden")
|
$(flash_success).removeClass("hidden");
|
||||||
$(errors).addClass("hidden")
|
$(errors).addClass("hidden");
|
||||||
$(form)[0].reset()
|
$(form)[0].reset();
|
||||||
|
$('#transaction_creditor').select2('data', null);
|
||||||
}).on("ajax:error", function(xhr, status, error) {
|
}).on("ajax:error", function(xhr, status, error) {
|
||||||
$(errors).removeClass("hidden")
|
$(errors).removeClass("hidden");
|
||||||
$(panel_ul).empty()
|
$(panel_ul).empty();
|
||||||
$.each(JSON.parse(status.responseText), function(index, val) {
|
$.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) {
|
}).on("ajax:complete", function(xhr, status) {
|
||||||
$(submit_button).val("Send it")
|
$(submit_button).val("Send it");
|
||||||
$(submit_button).attr('disabled', false);
|
$(submit_button).attr('disabled', false);
|
||||||
table.ajax.reload();
|
table.ajax.reload();
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
dataType: 'text'
|
dataType: 'text'
|
||||||
})
|
});
|
||||||
|
|
||||||
$(document).ready(ready)
|
$(document).ready(ready);
|
||||||
$(document).on('page:load', ready)
|
$(document).on('page:load', ready);
|
||||||
|
|
Loading…
Reference in a new issue