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
|
<script type="text/javascript">
$(function() {
$( "#state" ).autocomplete({
source: "dev2_search_autocomplete.php",
minLength: 2,
select: function (event, ui) {
$('#state_id').val(ui.item.id);
}
});
});
//gestion highlighting
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<span style='color:red;'>$1</span>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
</script> |
Partager