Utilizing Knockout.js, I've successfully created a pseudo-select list with the following code:
<div style="width:325px;height:500px;overflow:auto;" data-bind="template: { name: 'group-tmpl', foreach: explorer().categoryData }"></div>
However, this method lacks the styling and selected value functionality that a <select>
provides.
I attempted a different approach by using a select element within the data-bind attribute, but encountered an error due to the inability to employ a template in this scenario.
<select data-bind="options: explorer().categories, value: explorer().selectedCategory, optionsText:'name', template: 'group-tmpl'" size="15" />
In another attempt, I tried to include a template within the <option>
tag, only to find that it did not render correctly, displaying a list of [object Object]
.
One feature I aimed for was to have an image within each <option>
. While considering using CSS and jQuery to accomplish this after loading, it contradicts the purpose of utilizing Knockout.
I'm hopeful that there is a straightforward solution that I may have overlooked.