Reputation: 770
How to disable/enable button depending on whenever itemToAdd
javascript property is empty or not
<input type="text" data-bind='value:itemToAdd, valueUpdate: "afterkeydown"' />
<input type="button" data-bind="click:$parent.addItem" value="add" />
Thank you!
Upvotes: 0
Views: 238
Reputation: 16465
There is an enable
binding in knockout for this:
<input type="button" data-bind="click:$parent.addItem, enable: itemToAdd" value="add" />
Here is fiddle: http://jsfiddle.net/M2xDF/36/
Upvotes: 4