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
|
<SCRIPT>
$(function() {
$.ajax({
url:"<?php echo site_url('installations/accueil/autocomplete/'); ?>",
type:"GET",
dataType:"json",
data:{source: "source"},
success:function(source){
$("#recherche_installation").autocomplete({
source: function (request, response) {
var term = $.ui.autocomplete.escapeRegex(request.term)
, startsWithMatcher = new RegExp("^" + term, "i")
, startsWith = $.grep(source, function(value) {
return startsWithMatcher.test(value.label || value.value || value);
})
, containsMatcher = new RegExp(term, "i")
, contains = $.grep(source, function (value) {
return $.inArray(value, startsWith) < 0 &&
containsMatcher.test(value.label || value.value || value);
});
response(startsWith.concat(contains));
}
});
},
error:function(Installation){alert(Installation)},
});
$('#btn-recherche').click (function(reponse){
alert($('recherche_installation').val());
});
});
</SCRIPT> |
Partager