osem-fcy/app/assets/javascripts/osem-switch.js
Ana 81108290e5 Schedule update moved to program update
Schedule update updated a program attribute
2016-08-11 15:11:27 +02:00

37 lines
894 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) {
if(data.status != 'ok'){
alert("The schedule couldn't been updated");
}
}
$.ajax({
url: url,
type: method,
success: callback,
dataType: 'json'
});
});
});