I wrote a custom binding
that will perform like if binding
at the first, and work as visible binding
on the next.
ko.bindingHandlers.visibleIf = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext)
{
// Doing stuff here
// ...
return ko.bindingHandlers.if.init.apply(this, arguments);
},
update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext)
{
// Doing stuff here
// ...
ko.bindingHandlers.if.update.apply(this, arguments);
}
};
I used to wrap both of if.init
and if.update
and it works fine on KO 3.0
, I just noticed it was removed on KO 3.1
.
It is possible to wrap if.update
function on KO 3.1
? or do you have other suggestions that could help to achieve this?
Greatly appreciate it, Thanks.
You can add a property to your wrapper function that tells you if the IF-binding was fired before and/or if it has rendered its childs already. Then you can do exactly the same operations as you would have done with the former update callback.