2012-09-19 12:09:29 +00:00

49 lines
1.3 KiB
JavaScript

$(document).ready(function(){
//Boite de dialog surveillance
$('.dialogsurv').on('click', function(){
var title = $(this).attr('title');
var href = $(this).attr('href');
var windowhref = window.location.href;
var dialogOpts = {
bgiframe: true,
title: title,
width: 500,
height: 350,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...');
$(this).load(href);
$('#dialogsurv').keypress(function(e){
if (e.keyCode == 13){
e.preventDefault();
survSubmit();
}
});
},
buttons: {
Ok: function() { survSubmit(); },
Annuler: function() { $(this).dialog('close'); }
},
close: function() {
$('#dialogsurv').remove();
window.location.href = windowhref;
}
};
$('<div id="dialogsurv"></div>').dialog(dialogOpts);
return false;
});
});
function survSubmit(){
var buttons = $('#dialogsurv').dialog('option','buttons');
for( var button in buttons ){
$(":button:contains('"+button+"')").attr('disabled','disabled');
}
var formAction = $('#frmSurv').attr('action');
var serData = $('#frmSurv').serialize();
$('#frmSurv').replaceWith('<div id="frmSurv">Mise sous surveillance en cours...</div>');
$.post(formAction+'?'+serData, function(data) {
$('#frmSurv').html(data);
});
}