jQuery select2标记野生动物园中的错误 [英] jquery select2 tags bugs in safari
问题描述
将桌面调整为移动尺寸后,一切正常.这是Ruby on Rails应用程序.
Everything works fine on desktop resized to mobile dimensions. It is a Ruby on Rails app.
错误#1
我不知道该如何描述,但是当我在Safari的iphone上的输入中输入字母(调用select2时)时,输入每个字母后,它会上下摇动/上下摇动.
I don't know how to describe this but when I am entering letters into the input (that select2 is called on) on my iphone in Safari, it shakes/jolts/moves up and down after each letter is entered.
错误2
输入标签并在Iphone键盘上按完成"后,select2下拉菜单有时仍保持打开状态.这很挑剔.
After tags have been entered and you press "done" on the Iphone keyboard, the select2-dropdown will sometimes remain open. It is very finicky.
脚本:
$(document).on('page:change', function () {
$('.tags').select2({
placeholder: 'Click to select',
tokenSeparators: [','],
tags: true,
});
});
从视图中:
<%= f.input :tag_list, input_html: { class: 'tags', multiple: "multiple" }, collection: ActsAsTaggableOn::Tag.all, value_method: :name, label: "Tags" %>
Css
.modal-footer.photoform {
.select2-container {
margin: 10px 5px 15px 5px;
width: 90% !important;
float: left;
overflow: hidden;
li.select2-selection__choice {
background-color: white;
color: black;
}
}
input.select2-search__field {
width: 120px !important;
margin-bottom: 2px;
color: black;
}
}
推荐答案
这不是完美的解决方案,但这是我们从搜索中可以做到的最好的解决方案:
This is not a perfect solution but it is the best we can do from my searching:
$('select').select2({
ajax: {
url: '/example/api',
delay: 250
}
});
每个按键都会触发一个请求,我可以延迟一下吗? 默认情况下,无论用户何时更改搜索词,Select2都会触发一个新的AJAX请求.您可以使用ajax.delay选项设置对退回请求的时间限制.
A request is being triggered on every key stroke, can I delay this? By default, Select2 will trigger a new AJAX request whenever the user changes their search term. You can set a time limit for debouncing requests using the ajax.delay option.
这篇关于jQuery select2标记野生动物园中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!