Allow report options to be pulled using AJAX. Ajax is cool.

This commit is contained in:
James Cole
2016-11-09 19:25:09 +01:00
parent f0e0cdb49b
commit fe57648349
5 changed files with 47 additions and 4 deletions

View File

@@ -44,9 +44,24 @@ $(function () {
$('.date-select').on('click', preSelectDate);
$('#report-form').on('submit', catchSubmit);
$('select[name="report_type"]').on('change', getReportOptions);
getReportOptions();
});
function getReportOptions() {
"use strict";
var reportType = $('select[name="report_type"]').val();
$('#extra-options').empty();
$('#extra-options').addClass('loading');
console.log('Changed report type to ' + reportType);
$.getJSON('reports/options/' + reportType, function(data) {
$('#extra-options').removeClass('loading').html(data.html);
}).fail(function(){
$('#extra-options').removeClass('loading').addClass('error');
});
}
function catchSubmit() {
"use strict";
// default;20141201;20141231;4;5