我有一個頁面,使用KendoUI控件與淘汰賽的綁定,我需要使用Enter而不是Tab來瀏覽控件。使用輸入作爲選項卡與淘汰賽綁定和KendoUI下拉
我設法使其使用here發佈該解決方案通過Damien Sawyer,並增強其按住Shift鍵並輸入工作帶來極大的Andre Van Zuydam
ko.bindingHandlers.nextFieldOnEnter = {
init: function (element, valueAccessor, allBindingsAccessor) {
j$(element).on('keydown', 'input, select', function (e) {
var self = j$(this)
, form = j$(element)
, focusable
, next
;
var tabElements = 'input,a,select,button,textarea';
if (e.shiftKey) {
if (e.keyCode === 13) {
focusable = form.find(tabElements).filter(':visible');
prev = focusable.eq(focusable.index(this) - 1);
if (prev.length) {
prev.focus();
} else {
form.submit();
}
}
}
else
if (e.keyCode === 13) {
focusable = form.find(tabElements).filter(':visible');
var nextIndex = focusable.index(this) === focusable.length - 1 ? 0 : focusable.index(this) + 1;
next = focusable.eq(nextIndex);
next.focus();
return false;
}
});
} };
的建議(我的代碼使用Ĵ$,而不是$ jQuery的,因爲項目也使用mootools和我重新定義jQuery爲j $)
但是,我有一個kendoui DropDown列表的問題。它不是或元素的問題,所以它不會獲得焦點(相反,它是一個具有特殊類和unselecteable =「on」屬性的跨度)。
我應該如何更新ko綁定代碼以將焦點設置爲Enter下拉?它與標籤
感謝
這聽起來像你需要定製有點對劍道降了下來。你可以發佈你的代碼看起來像當前,也許創建一個[小提琴](http://jsfiddle.net)? – Goose
是的,但我不知道該怎麼做。我用代碼更新了帖子,並鏈接到原始答案,我從中獲得瞭解決方案 – bzamfir