我正在使用 rails app 并运行 bootstrap ui 库。该应用程序在所有浏览器上运行良好,除了 <=IE8 ....
经过一段时间的调查,我发现了产生错误的代码部分:
编译的 application.js :
u.bind("keydown",function(t){0!==k.matches.length&&-1!==a.indexOf(t.which)&&(t.preventDefault(),40===t.which?(k.activeIdx=(k.activeIdx+1)%k.matches.length,k.$digest()):38===t.which?(k.activeIdx=(k.activeIdx?k.activeIdx:k.matches.length)-1,k.$digest()):13===t.which||9===t.which?k.$apply(function(){k.select(k.activeIdx)
和 UI Bootstrap 模板未编译:
element.bind('keydown', function (evt) {
//typeahead is open and an "interesting" key was pressed
if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) {
return;
}
evt.preventDefault();
if (evt.which === 40) {
scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
scope.$digest();
} else if (evt.which === 38) {
scope.activeIdx = (scope.activeIdx ? scope.activeIdx : scope.matches.length) - 1;
scope.$digest();
} else if (evt.which === 13 || evt.which === 9) {
scope.$apply(function () {
scope.select(scope.activeIdx);
});
} else if (evt.which === 27) {
evt.stopPropagation();
resetMatches();
scope.$digest();
}
});
有谁知道我如何——至少——修复 IE8 上的这个错误?
谢谢 :)