KnockoutJS: How to update view model after a user copy'n'paste into a text field?

前端 未结 2 565
礼貌的吻别
礼貌的吻别 2021-02-01 05:32

I am working on a website that auto populates search result in a table after user entered some text in the input text box (similar to google instant search).

I managed t

2条回答
  •  甜味超标
    2021-02-01 05:48

    You can use valueUpdate:'input'. I have testet it to work in Opera, Firefox and Chrome. I'm on a Linux box, so I can't test it in IE. Check this fiddle

    UPDATE: I have now testet it in IE8, and it doesn't work. But using the following seems to work.

    valueUpdate:['afterkeydown','propertychange','input']
    

    Thanks to Michael Best for his comment about this :) I have updated the fiddle

    UPDATE okt 2014: As kzh mention in a comment below, in one of the later versions of Knockout.js the textInput binding was added. This binding handles this scenario and has build in browser quirks handling http://knockoutjs.com/documentation/textinput-binding.html

提交回复
热议问题