【问题标题】:KO binding is not working in IE10 and IE11KO 绑定在 IE10 和 IE11 中不起作用
【发布时间】:2015-06-10 06:35:19
【问题描述】:

这是我的数据绑定

<input type='text' data-bind="value: duration" id="duration" />

而且我有自定义 javascript 代码来防止用户提交非数字文本的“持续时间”,它会在持续时间字段的 keyup 事件上触发。 这在 chrome、firefox 和 IE9 中运行良好。但不适用于 IE10 和 IE11

这是我的脚本

$(document).on('keyup', '#duration', function () {
        var textvalue = this.value.replace(/[^0-9\.]/g, '');
        this.value = !textvalue ? '' : parseInt(textvalue, 10);
    });

问候

【问题讨论】:

标签: knockout.js internet-explorer-10 internet-explorer-11


【解决方案1】:

我知道这是一篇旧帖子,但如果其他人遇到这个问题,我今天遇到了类似的问题,发现还有另一个用于文本输入的 ko 绑定,称为 textInput。我建议改用它。 textInput 绑定会立即更新,并且在 IE11 中对我来说工作正常。

http://knockoutjs.com/documentation/textinput-binding.html

<input type="text" data-bind="textInput: name" />

另外,jQuery 有一个不错的数字输入插件。

https://www.nuget.org/packages/jQuery.Numeric/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-27
    • 2019-01-09
    • 1970-01-01
    • 2012-12-08
    • 1970-01-01
    • 2014-11-16
    • 2013-12-02
    • 2013-11-13
    相关资源
    最近更新 更多