custom binding with same functionality as 'with' cannot find ko.utils.cloneNodes

113 views
Skip to first unread message

oscar.f...@gmail.com

unread,
Dec 4, 2012, 7:20:38 PM12/4/12
to knock...@googlegroups.com
Hi,

I got a collection of custom bindings (see http://pagerjs.com/demo/ for demo). One of the bindings (page) can be supplied a parameter "with" or "withOnShow" that should work like the default binding "with" (see http://pagerjs.com/demo/#!/change_binding_context for an example). The problem I got at the moment is twofold:

1. I'm trying to emulate the code for the default with-binding found at https://github.com/SteveSanderson/knockout/blob/master/src/binding/defaultBindings/ifIfnotWith.js but I cannot find "ko.utils.cloneNodes". There is no cloneNodes-method on ko.utils (ko 2.2.0). Am I looking at the wrong code?

2. When the html-code that contains the page-binding is reevaluated (by e.g. my with-binding) I'm preventing the page-binding from creating another instance by checking if a page-binding-instance (pager.Page-instance) already exists for the element. If it already exists I simply return { controlsDescendantBindings: true}. Everything except one thing seem to work - a foreach-binding.
You can see the problem at http://jsfiddle.net/xkCea/33/ .  Anyone got any idea why the foreach-binding is not working (while all the other bindings work)? You can see another fiddle at http://jsfiddle.net/xkCea/27/ (that access another version of pager.js) where the foreach-binding is working (but the page-binding is reevaluated). The only difference in the source code is that the newer one is returning {controlsDescendantBindings: true} if an instance already exists instead of creating a new page-instance. 

Regards,
Oscar
Reply all
Reply to author
Forward
0 new messages