Kelly Cline
Kelly Cline

Reputation: 2246

knockout data-bind inputmask prevents change event

I have a data-bind that looks like this

<td><input type="text" data-bind="inputmask: { value:PayRate}, event:{change: $root.payRateChanged}" /></td>

The change event does not fire. If I use the same syntax, but replace change with blur, the blur event does fire, but I really need the change event rather than blur.

If I change inputmask: {value:PayRate} to simply value:PayRate, the change fires, but now I have lost my inputmask-ing.

How can I invoke inputmask and still get the change event?

Upvotes: 0

Views: 176

Answers (1)

TheRightChoyce
TheRightChoyce

Reputation: 3084

Try adding value: PayRate to your input markup as well

<td><input type="text" data-bind="value: PayRate, inputmask: {value:PayRate}, event:{change: $root.payRateChanged}" /></td>

Without that, the input isn't actually getting bound to any value, thus it has no way to trigger a change event.

Upvotes: 1

Related Questions