0

我正在使用 hasfocus 来强制关注这样的特定元素

this.inputHasFocus = ko.observable();
this.forceInputFocus = ko.computed({
    read: function () {
        return false;
    },
    write: function (value) {
        this.inputHasFocus(true);
    }
}, this);

inputHasFocus 绑定到我想要强制聚焦的输入上,而 forceInputFocus 绑定到我不想从输入中窃取焦点的所有其他元素。

请在 Firefox 中试试这个小提琴,它可以工作(按箭头按钮,输入聚焦) http://jsfiddle.net/AWHhr/2/

试试Chrome,它没有,按下箭头按钮时不会触发写入方法。怎么了?有什么更好的方法来解决这个问题?

src代码,相关代码从第94行开始 https://github.com/AndersMalmgren/Knockout.Combobox/blob/master/src/knockout.combobox.js

编辑:孤立的问题http://jsfiddle.net/ygCEs/2

4

0 回答 0