在jQuery Mobile中有过滤列表视图。将文本输入过滤器后,列表会被过滤,但按下GO按钮不会隐藏键盘。jQueryMobile - 在listview中过滤并按下键盘上的Go不会隐藏键盘
用户希望按下GO后键盘会隐藏。 有什么办法可以做到这一点?
在jQuery Mobile中有过滤列表视图。将文本输入过滤器后,列表会被过滤,但按下GO按钮不会隐藏键盘。jQueryMobile - 在listview中过滤并按下键盘上的Go不会隐藏键盘
用户希望按下GO后键盘会隐藏。 有什么办法可以做到这一点?
你必须从输入字段使用JavaScript手动删除的重点是这样的:
$('.ui-listview-filter .ui-input-text').live('keyup', function(event) {
if (event.keyCode == 13) {
// 'Go' pressed
$('.ui-listview-filter .ui-input-text').trigger('blur');
}
});
您可能想要在按下按键后尝试更改焦点。例如:
//this will un-select the text box, hiding keyboard
$('#searchInputId').blur();
//this will focus on something else, hiding keyboard
$('#somethingOtherThanTheSearch').focus();
Pablo的答案的变体,它在我的jQuery(移动)的过时的版本作品:
// this is here to close the on-screen keyboards of mobile devices when the "go" button is used
$("input[data-type='search']").on('keyup', function(event) {
if (event.keyCode == 13) { // Enter or 'Go' pressed
event.target.blur(); // remove focus on the search field so keyboard goes away
}
});
这正是我所需要的!谢谢。 – rdkit 2012-08-10 09:47:08