4
我由於某種原因沒有在IE8更新這個非常簡單的觀察到的元素淘汰賽觀察到的元素不更新IE正常
<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>
因此,點擊後進入時,應顯示inputed到文本框中的值。一切都很好,在Mozilla,歌劇,鉻。 IE瀏覽器沒有看到任何更改,並始終以空字符串提醒。爲什麼?
Here you can run this piece of code
我不完全理解比其他瀏覽器的IE瀏覽器的行爲差異,但它的出現改變事件不會被觸發_before_提交事件。 Knockout依靠這些事件來保持視圖模型是最新的。你可能需要調整你的代碼來解決這個問題。 – 2012-08-12 20:11:44