简体   繁体   中英

Knockout observable array, get updated item value on change event

I'm using knockout.js for an editable table, and I'm trying to fire a validation function when an input field value within the table is changed.

I have tried using an editable computed observable: change event on select with knockout binding, how can i know if its a real change (mhu's answer)

I have tried using observable extenders: KO Extenders

I have also tried using the change event:

JSFiddle !

Each time I have tried, only the original value is returned.

What is the standard way to intercept the new value of an observableArray item in order to validate the new value? Is this not bread-and-butter stuff for KO?

Change your databind statment from

data-bind="attr: { value: itemValue  }, event: { change: $parent.itemChanged }"

to

data-bind="value: itemValue, event: { change: $parent.itemChanged }"

working fiddle: http://jsfiddle.net/hztaS/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM