Title pretty much says it all. I'm just wondering if anyone would know why the value binding on knockout doesn't create/set a value attribute on the input element in the document.
Asked
Active
Viewed 213 times
0
-
4Not sure exactly what you're asking, but in most cases the `value` attribute on an `` element is the initial value of the field. Once active in the page, the `.value` property is the current value. Attribute and property are not the same. – jfriend00 Dec 02 '13 at 18:41
-
Please post some code or even better a repro in JSFiddle! – nemesv Dec 02 '13 at 19:48
-
@jfriend00 That makes sense thanks. I also found [this](http://stackoverflow.com/q/6003819/1165441). If you would answer with your comment I would accept so this question is closed. Looks like my problem is with the printer plugin. – edhedges Dec 02 '13 at 19:52
-
@nemesv The problem is that I'm using a printing plugin to print specific element and when the value property is changed for an input type text the printer plugin is looking at the value attribute and not the property so it ends up being a blank input. – edhedges Dec 02 '13 at 19:53
1 Answers
1
Per request, making my comment into an answer:
The value attribute on an <input value="foo">
element is the initial value of the field. Once active in the page, the .value
property is the current value. Attribute and property are not the same.
If you have some flawed piece of code (e.g. the printing plugin) that you're trying to work with that is using the attribute instead of the property, then I supposed you could set the attribute to match the property before calling that printing plugin or you could path the printing plugin to correctly access the property.

jfriend00
- 683,504
- 96
- 985
- 979