mbest/knockout.punches

Enabling Punches breaks foreach/checkbox combination

Closed this issue · 1 comments

I have a list of checkboxes that are being populated by a template, and use the "checked" data-binding (on the checkbox element) to determine if the checkbox should be automatically checked after loading data and applying bindings to the DOM.

If I enable punches on the page, my checkboxes fail to auto-check themselves; however if I do not enable punches, it works as intended. Any thoughts what may be causing this?

Here is an example fiddle with punches enabled: http://jsfiddle.net/emes001/u42wubyw/

To reproduce the problem, run the solution as is, then comment out ko.punches.enableAll(); and run it again.

The problem comes from the binding order. Because Punches re-writes the attr binding, Knockout doesn't know to bind it before the checked binding. You can fix this by adding ko.bindingHandlers.checked.after.push('attr.value');: http://jsfiddle.net/u42wubyw/2/

I'll add that to Punches as well.