osem-fcy/app/assets/javascripts/osem-switch.js
Ana 5761e0f7a4 Using flash instead of alerts in the schedule
Using flash instead of alerts in the schedule to notify errors.

Also, a message shown when a schedule is successfully created.
2016-08-11 15:11:27 +02:00

37 lines
873 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'){
showError(data.status);
}
}
$.ajax({
url: url,
type: method,
success: callback,
dataType: 'json'
});
});
});