javascript - KnockoutJS IF binding - keep DOM -


the if binding removes dom , stops executing inner data-bind attributes if condition false.

is possible keep dom when condition false? want stop executing data-bind when condition false not wish remove dom due jquery bindings etc.

i came following solution delays knockout binding application until condition satisfied.

it not remove binding when condition becomes false not necessary in case.

ko.bindinghandlers['applywhen'] = {   init: function() {     return { controlsdescendantbindings: true };   },   update: function(element, valueaccessor, allbindings, model, bindingcontext) {     if (!element.bindingapplied && boolean(ko.unwrap(valueaccessor()))) {       element.bindingapplied = true;       ko.applybindingstodescendants(bindingcontext, element);     }   } }; 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -