$(function() {
function log( message ) {
$( "<div>" ).text( message ).prependTo( "#log" );
$( "#grille" ).scrollTop( 0 );
}
$( "#my_ac" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "<?php echo url_for('jsonfile') ?>",
dataType: "json",
data: {
limit: 100,
q: request.term
},
success: function( data ) {
response( $.map( data.images, function( item ) {
return {
label: item.nom,
image: item.image,
id: item.id
}
}));
}
});
},
minLength: 3
})
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
$('#grille_table').append( '<tr><td><a href="/add/' + item.id + '"><img src="/upload/' + item.image + '" width="100" height="100" title="'+ item.label +'"></a></td><td>'+ item.label +'</td></tr>' );
return $( "" )
};
});
So this is an autocomplete jquery script, I try to display the resut in a table instead of the select field which is the default behaviour but I dont really understand the renderItem method and I still have some graphics issue (pic)...Any idea how the method works and how to have better result with it ?