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
I added few updates for keep Icon when selected the item. Working Perfect.
$(function () {
$.widget("custom.iconselectmenu", $.ui.selectmenu, {
_renderItem: function (ul, item) {
var li = $("- "),
wrapper = $("", { text: item.label });
if (item.disabled) {
li.addClass("ui-state-disabled");
}
$("", {
style: item.element.attr("data-style"),
"class": "bl-icon " + item.element.attr("data-class")
})
.appendTo(wrapper);
return li.append(wrapper).appendTo(ul);
}
});
$("#IconDropdown").iconselectmenu({
create: function (event, ui) {
var widget = $(this).iconselectmenu("widget");
$span = $(' ').html(" ").appendTo(widget);
$("#" + this.id + 'selected').attr("class", $("#IconDropdown option:selected")[0].getAttribute('data-class'));
},
change: function (event, ui) {
$("#" + this.id + 'selected').attr("class", ui.item.element[0].getAttribute('data-class'));
}
}).iconselectmenu("menuWidget").addClass("ui-menu-icons");
});