osem-fcy/app/assets/javascripts/osem-switch.js
Ana 6f0cdc64c3 Introduce a "Save" button for the admin schedule
The changes were saved after you drop an event, and now it only saves the schedule when you're done with the changes and click the "Save" button.
2017-01-12 11:37:38 +01:00

35 lines
867 B
JavaScript

$(function () {
$("[class='switch-checkbox']").bootstrapSwitch();
$('input[class="switch-checkbox"]').on('switchChange.bootstrapSwitch', function(event, state) {
var url = $(this).attr('url') + state;
var method = $(this).attr('method');
$.ajax({
url: url,
type: method,
dataType: 'script'
});
});
$("[class='switch-checkbox-schedule']").bootstrapSwitch();
$('input[class="switch-checkbox-schedule"]').on('switchChange.bootstrapSwitch', function(event, state) {
var url = $(this).attr('url');
var method = $(this).attr('method');
if(state){
url += $(this).attr('value');
}
var callback = function(data) {
showMessage($.parseJSON(data.responseText).errors, 'error');
}
$.ajax({
url: url,
type: method,
error: callback,
dataType: 'json'
});
});
});