Just stumble upon it yourself; I can understand why this was done so, but itβs convenient to set the default visibility of none of the last loaded items on the page so that they do not blink as scripts load. The most enjoyable way I could find is to simply create a normal binding:
ko.bindingHandlers.forceVisible = { update: function(el, f_valueaccessor, allbindings, viewmodel, bindingcontext) { if(ko.unwrap(f_valueaccessor())) el.style.display = 'inherit'; else el.style.display = 'none'; } };
You should be a little careful when setting styles; if you use a div , and your CSS sets it to display:inline-block , then this code will not work - it will have a block display when applying inherit . However, this simple solution was suitable for my use.
source share