Vit*_*kov 4 data-binding internet-explorer observable knockout.js
我有这个非常简单的可观察元素,由于某些原因在IE8中没有更新
<body>
<form data-bind="submit: show">
<input type="text" data-bind="value: someText" />
</form>
<script type="text/javascript">
var ViewModel = function () {
var self = this;
self.someText = ko.observable('initial value');
self.show = function () {
alert(self.someText());
self.someText('');
}
}
ko.applyBindings(new ViewModel());
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
因此,单击enter时,应显示输入到文本框中的值.mozilla,opera,chrome都很好.IE没有看到任何更改,并始终使用空字符串进行警报.为什么?
在这里你可以运行这段代码
对不起,我应该小心谷歌.问题出现在不同的事件之后,应该更新可观察的元素.IE的小修复看起来像这样
<input type="text" data-bind="value: someText, valueUpdate: 'keydown'" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2619 次 |
| 最近记录: |