Closed nguy0621 closed 10 years ago
Hmmm... no, it does not. I've never written code for that scenario (or really considered it for that matter). How would you recommend binding options as groups?
stickit (http://nytimes.github.io/backbone.stickit/) has support for select/optgroup, but it used the optgroup's label as a key to map to an array of options of the optgroup. That doesn't work in rare cases where some optgroup share the same label. A better data structure could be:
[ {group_label: optgroup_label_1, options: [ {value: v1_1, label: l1_1}, {value: v1_2, label: l1_2} ... ] }, ... {group_label: optgroup_label_n, options: [ {value: vn_1, label: ln_1}, {value: vn_2, label: ln_2} ... ] } ]
Of course, the "group_label", "value", and "label" should be configurable. Thanks.
I don't think Epoxy is going to try to solve this problem. The data structure required to support the output would be way too specific, and therefore not appropriate as a single model field provided to a binding.
Looking at your proposed data structure: that should probably be the result of a custom mapping function across multiple data structures in your model; the relationships of which would be difficult to prescribe as a feature of the Epoxy framework. Once that data is generated, it would make the most sense just to hand that composition off to a designated view rendering function for display. At that point, there's been enough case-specific code written that you may as well hook the render triggers up with a custom event (which is all a binding framework would do anyway).
Does it support binding to a multiselect with optgroup?