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
| $("#tags").autocomplete({
minLength: 2,
source: function(req, add){
$.getJSON("modules/accueil/rechercheRpc.php?callback=?", req, function(data) {
var suggestions = [];
$.each(data, function(i, val){
suggestions.push({
"id": val.id,
"libelle": val.libelle
});
});
add(suggestions);
});
},
select: function(e, ui) {
$("#id_patient").val(ui.item.id);
var page = (ui.item.id == 0) ? "index.php?module=patient&action=edition_patient" : "index.php?module=patient&action=patient";
$("#recherche_patient").attr("action", page);
$("#recherche_patient").submit();
},
change: function() {
$("#tags").val("").css("top", 2);
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a style='font-size: 80%;'>" + item.libelle + "</a>" )
.appendTo( ul );
}; |
Partager