I have a knockout custom binding called groupedOptions
which binds the options of a select
list with optgroup
s. This does the same as the standard options binding but includes logic to handle options groups.
The binding worked fine under knockout v2.3 but stopped working after upgrading to v3.3. After the update it would no longer bind the value correctly.
Having a look at the source for the value binding in the new version it has some code to tell it to run after the options binding:
ko.bindingHandlers['value'] = {
'after': ['options', 'foreach'],
'init': function (element, valueAccessor, allBindings) {
...
Changing this to:
ko.bindingHandlers['value'] = {
'after': ['options', 'foreach', 'groupedOptions'],
'init': function (element, valueAccessor, allBindings) {
...
Will work but seems a bit hacky to me. Does anyone have any idea of what the best practice way to do this is.
In other words: if I have a custom binding that needs to be run before a binding that is defined in knockout how would I do it without editing the knockout source?