【发布时间】:2016-07-27 03:39:02
【问题描述】:
HTML 代码
<input type="text" data-bind="value: nextName">
可观察
nextName: KnockoutComputed<string>;
currentName: KnockoutObservable<string>;
constructor()
{
this.nextName = ko.pureComputed(
{
read: () => this.currentName(),
write: (value: string) =>
{
this.currentName(value);
if ((value) && value.trim().length > 0)
this.runSearch();
}
}, this);
}
用户按下回车后 - 例如,在 Chrome 中搜索将正常执行,但在 Internet Explorer 中则不执行。
我尝试使用与valueUpdate:'afterkeydown' 的绑定,但这将在每个字符之后执行搜索——这不是我想要实现的。
【问题讨论】:
标签: knockout.js data-binding typescript