mk_yo
mk_yo

Reputation: 770

input type button enable/disable attribute

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" />

here's jsfiddle

Thank you!

Upvotes: 0

Views: 238

Answers (1)

Artem Vyshniakov
Artem Vyshniakov

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

Related Questions