In one of my ASP.Net project I have used the chosen-image (https://github.com/djgrant/chosen-image) for add images to drop down list.
I added chosen library as well. Everything work fine for chosen. It will create the chosen list view if I use following code in document load function.
$(document).ready(function () {
$(".chosen-select").chosen({
disable_search_threshold: 10
});
}
Then I wanted to add images to list view. So i added chosen-image js file and css files and changed the above code as following.
$(document).ready(function () {
$(".chosen-select").chosenImage({
disable_search_threshold: 10
});
}
in the back end I am binding the images to list view.
protected void Bind_BuyerImages() {
if (cmbBuyer != null)
{
foreach (ListItem li in cmbBuyer.Items)
{
li.Attributes["data-img-src"] = "../Buyers/" + li.Value;
}
}
}
In the list view all the images are showing but page is refreshing continuously. How can i prevent this ?
I don't know how the results of
chosenImageshould look like, because I can't see the example from theGit, but there's a forkedchosenversion which allow you to customize theiteminside thelistthat you can use from herethen you can call the function like this
if you need to change the style of the
item, just addclassfor it's template (imgandspanfor this example), then style it with theclassfrom theCSSthen when you bind the
list, change it toEdit:
After I recheck it, it only pass 2 parameters in the
templatefunction, so you need to changeto
Here's an example of the custom template: Demo (The
CSSdoesn't load when I try it in the Fiddle), try to change your template to what you need.