1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
$(document).ready(function(){
$( "#info_siege" ).validate({
rules: {
'data[Siege][town]':'townValidation2',
'data[Siege][cp]' : 'postalcode',
},
});
$.validator.messages.required = 'Ce champ est obligatoire.';
$('#info_siege').submit(function(e) {
e.preventDefault();
var data = {
id_centre: $('#id_centre').val(),
name : $('#siege_name').val(),
address1 : $('#siege_adress1').val(),
address2 : $('#siege_adress2').val(),
cp : $('#siege_cp').val(),
town : $('#siege_town').val(),
town_id :$('#siege_town_id').val(),
type :$('#siege_type').val(),
};
jQuery.ajax({
url : "<?php echo $this->Html->url('/employes/save_siege'); ?>",
type: "POST",
data : data,
dataType: "json",
success:function(data)
{
$( "#list_centre").empty();
$.each(data.listNameCentre, function(i,item){
$( "#list_centre").append($("<option>",{
value: item['id'],
text: item['name']
}));
});
$('#list_centre').append($("<option>",{
value: 0,
text: 'Ajouter un nouveau siége',
}));
$('#list_centre').val(data.id_siege);
$('#overlay').hide();
},
});
});
}); |
Partager