I use jquery UI - Select Menu to build a List with picture. I follow this link and it\'s good. But When you select an item, just the text is copying, not the picture. I explain
And here another solution:
And the associated CSS
.ui-widget
{
font-size: 1em;
}
.ui-widget-content
{
border-style: none;
}
/*Affichage des options*/
.ui-selectmenu-menu .ui-menu.customicons .ui-menu-item
{
padding: 0.5em 0 0.5em 2.1em;
background-repeat: no-repeat;
}
/*Agrandir sinon 16px par defaut*/
.ui-selectmenu-menu .ui-menu.customicons .ui-menu-item .ui-icon
{
height: 24px;
width: 24px;
top: 0.1em;
}
.TFOlstFiltreImg
{
width: 100px;
}
.TFOSizeImgSelected
{
position:absolute;
height: 24px;
width: 24px;
left:35%;
right:auto;
margin-top:-12px; /* 24/2*/
top:50%;
background-size:24px 24px;
background-repeat:no-repeat;
}
.TFOOptlstFiltreImg
{
background-size:24px 24px;
background-repeat:no-repeat;
}
And here another sample. Instead of add a span, just add a picture
$("#people")
.TFOiconSelectImg({
create: function (event, ui) {
var widget = $(this).TFOiconSelectImg("widget"); var $SpanTxt = widget.children(":last");
$span = $(' ').appendTo($SpanTxt);
$span.attr("style", $(this).children(":first").data("style"));
},
change: function (event, ui) {
var widget = $(this).TFOiconSelectImg("widget"); var $SpanTxt = widget.children(":last");
$span = $(' ').appendTo($SpanTxt);
$span.attr("style", ui.item.element.data("style"));
//$("#" + this.id + 'ImgSelected').attr("style", ui.item.element.data("style"));
}
}).TFOiconSelectImg("menuWidget").addClass("ui-menu-icons customicons");
modify css with
.TFOSizeImgSelected
{
position:absolute;
height: 24px;
width: 24px;
left:2em;
}
.TFOOptlstFiltreImg
{
background-size:24px 24px;
background-repeat:no-repeat;
}