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 62 63 64 65 66 67 68
| $(function () {
GetElems();
$("#Ajouter").click(function () {
EditionElem(-1);
});
$("#MPEditElem").dialog({
autoOpen: false,
modal: true,
width: "500px",
buttons: {
Fermer: function () {
$(this).dialog("close");
GetElems();
},
Valider: function () {
$('.error').hide();
ValidationElem();
}
}
});
});
function EditionElem(RowID) {
$.ajax({
type: "POST",
url: "Lst_Element.aspx/GetElement",
data: '{"IdElem":' + RowID + ',"PageEnCours":"' + document.location.href.toString() + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d != null) {
$('#MPEditElem').dialog('option', 'title', msg.d.titre);
BuildTable(msg.d);
$('.error').hide();
$("#MPEditElem").dialog("open");
}
else {
var Ret = new function () {
this.Reussi = false;
this.Msg = "Problème récupération élément";
}
AfficheMsgRetour(Ret)
}
},
error: function () {
alert('Erreur récupération élément!');
}
});
}
function BuildTable(msg) {
var table = '<table>';
if (msg.Id == "-1") {
table += '<tr><td class="FormLib">Libellé</td><td class="FormCell"><input type="text" id="txtNom" /><br /><label class="error" for="txtNom" id="Nom_error">Champs Libellé obligatoire.</label></td></tr>';
table += '<tr><td class="FormLib">Dimension</td><td class="FormCell"><input type="text" id="txtDim" /></td></tr>';
}
else {
table += '<tr><td class="FormLib">Libellé</td><td class="FormCell"><input type="text" id="txtNom" value="' + msg.Libelle + '"/><br /><label class="error" for="txtNom" id="Nom_error">Champs Libellé obligatoire.</label></td></tr>';
table += '<tr><td class="FormLib">Dimension</td><td class="FormCell"><input type="text" id="txtDim" value="' + msg.Dimension + '"/></td></tr>';
}
table += '<input type="hidden" id="hidId" value="' + msg.Id + '"/></table>';
$('#ContenuEditElem').html(table);
}; |
Partager