SteveSanderson/knockout — Issue #285: Can't immediately access dynamically added attribute of element passed to custom binding.
Author: ryanac
Created: 2012-01-17 21:43:02+00:00
State: open

Hello, I've run into a small problem that could be the fault of jQuery, Knockout or myself for not understanding what's happening :P but I'm unsure which. I originally posted this on the forum and figured out a work around (by avoiding this scenario), but I believe there still may be a problem here and just wanted to make sure.

**Here's the fiddle:**
http://jsfiddle.net/JZBsR/7/

**Here's the problem:**
Open console and click the "add item" button two times. I can't get the dynamically added "page" attribute on the first click even though it SEEMS to be in the DOM element passed into ko's binding handler (check console.)

Yet, I can't seem to get the value (it says its undefined even though it's visually there), then on the second click it appears to work from then on. Also, I included the class attribute in console output to show that, if the attribute is there ahead of time it has no problem getting it.

-ryan