I've got list of products for my autocomplete and different pictures for them. How can I put the radiobuttons with pictures under each product? This is my code for autocomplete so far
function create_rbuttons(item){
var str = $();
if(item.PicId !=null){
for(i=0;i<item.PicId.length;i++){
debugger;
str = str + $('<input type="radio" name="rbtnCount" />');
}
}
return str;
}
$('.SliderBox').on("focus",function () {
$(this).autocomplete({
delay: 500,
minLength: @(Model.SearchTermMinimumLength.ToString()),
source: '@(Url.RouteUrl("ProductSearch"))',
select: function( event, ui ) {
$(this).val(ui.item.label);
var box_id = $(this).closest('.search-box').attr('value');
$('.Picture'+box_id+' img').attr('src',ui.item.productpictureurl).width(100).height(100);
$('#Picture'+box_id+'Id').attr('value',ui.item.PicId[0])
$('.Text'+box_id+' input').attr('value',ui.item.label)
$('.Link'+box_id+' input').attr('value',ui.item.producturl);
return false;
}
})
.data("ui-autocomplete")._renderItem = function( ul, item ) {
var t = item.label;
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>@(true ? Html.Raw("<img src='\" + item.UrlsArr[0] + \"'>") : null)" + t + "</a>")
.append("<a>" + t + "</a>")
.append(create_rbuttons(item))
.appendTo(ul);
};
PicId is an array, where I keep id of pictures. UrlsArr — where I keep paths to them