ko.applyBindingsToNode vs. ko.applyBindingsToDesce

2019-04-05 02:32发布

Both functions allow to replace/modify binding context and apply it to unbound nodes. "Unbound" means that my own custom bindings that want to use these useful functions must always return { controlsDescendantNodes: true } in init function.

So I cannot understand what the difference between them?

标签: knockout.js
1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-05 02:45

When using ko.applyBindingsToNode or in 3.0 ko.applyBindingAccessorsToNode you are able to directly supply the bindings that you want to use for a specific element (so, it would not care about data-bind).

When calling ko.applyBindingsToDecendants you would be applying the bindings that already exist on the child elements (in data-bind attributes by default) of the supplied root node.

查看更多
登录 后发表回答