- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在一个页面上有多个自动完成。
当我对所有文本字段使用 jQuery UI AutoComplete 时,它会添加表单的动态选择列表
<ul id="ui-id-1" tabindex="0" class="ui-menu ui-widget ui-widget-content ui-autocomplete ui-front" style="top: 103px; left: 1678px; width: 256.828px; display: none;">
<li class="ui-menu-item"><div id="ui-id-234" tabindex="-1" class="ui-menu-item-wrapper">Entry 1</div></li>
</ul>
有一个 CSS 样式,ui-autocomplete
,我需要针对每个字段进行不同的调整。但是如何根据它们描述的 DOM 元素定位个人 ui-autocomplete
选择框?
为什么向生成的任何选择列表框添加属性(例如 "domElement=myID"
)以便轻松定位如此困难?
没有我可以依赖的位置前后依赖。选择列表添加在 DOM 的底部。
自动完成之一的示例:
$('#addModalUserSearch').autocomplete({
source: function( request, response ) {
$.ajax({
url: "getAdminAddUserChoices",
dataType: "json",
type: "get",
data: {
'term': request.term,
'org': $('#adminUserOrg').val()
},
success: function( data ) {
response ($.map (data, function (item) {
return {
label: item.value,
value: item.key
}
}));
}
});
},
minLength: 2,
delay: 100,
select: function(event, ui) { ..}
我需要做类似的事情
.ui-autocomplete-1 {
top: 120px !important;
left: 80% !important;
}
.ui-autocomplete-2 {
top: 5%;
left: 60%;
}
最佳答案
当涉及到自动完成时,有几种方法可以注入(inject)您自己的 CSS。您的帖子并没有真正显示您想要什么,所以我会尽量含糊其词。
考虑以下几点:
$(function() {
$('#addModalUserSearch').autocomplete({
classes: {
"ui-autocomplete": "user-search"
},
source: function(request, response) {
$.ajax({
url: "getAdminAddUserChoices",
dataType: "json",
type: "get",
data: {
'term': request.term,
'org': $('#adminUserOrg').val()
},
success: function(data) {
response($.map(data, function(item) {
return {
label: item.value,
value: item.key
}
}));
}
});
},
minLength: 2,
delay: 100,
select: function(event, ui) {
//...
}
});
});
.user-search {
top: 120px !important;
left: 80% !important;
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="ui-widget">
<label for="addModalUserSearch">User: </label>
<input id="addModalUserSearch">
</div>
由于远程源,这个例子基本上是非功能性的,但是你仍然可以看到基本的列表生成:
<ul id="ui-id-1" tabindex="0" class="ui-menu ui-widget ui-widget-content ui-autocomplete user-search ui-front" style="display: none;"></ul>
可以看到类user-search
已列出,可以由 CSS 专门为此自动完成调用和设置样式。
您也可以考虑使用 position
选项。
position Type: Object, Default:
{ my: "left top", at: "left bottom", collision: "none" }
Identifies the position of the suggestions menu in relation to the associated input element. The of option defaults to the input element, but you can specify another element to position against. You can refer to the jQuery UI Position utility for more details about the various options.
另一种更复杂的方法是使用 _RenderMenu
扩展点。由于 AutoComplete 使用 Menu 来构建选择列表,您可以结合它来更深入地管理它的外观。
_renderMenu( ul, items ), Returns: jQuery (plugin only)
Method that controls building the widget's menu. The method is passed an empty
<ul>
and an array of items that match the user typed term. Creation of the individual<li>
elements should be delegated to_renderItemData()
, which in turn delegates to the_renderItem()
extension point.
希望这对您有所帮助。
关于jquery - 如何针对不同的 AutoComplete 的 ui-autocomplete 定位单个 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56026419/
我正在尝试让 Ace Editor 支持我自己的查询语言的自动完成功能。 查询本身如下所示 city:newyork color:red color:blue 在上述情况下,我希望用户在输入“c”时可
我有一个 Material-UI 组件,我正在使用它,您可以在其中输入某人的姓名,它将提供一个可供选择的人员列表。这是一个非常标准的用例,但是我需要表单中的所选项目与标签不同。 目前,如果您选择标有
我开始使用 atom IDE 来编写 HTML+ CSS 代码。 autocomplete-atom-api 被激活,但仍然没有代码自动完成,也没有当我按下 ctrl+space 时。 这是我的 ke
我成功地使用了 API,但今天早上遇到错误,文本框中出现“糟糕!出了点问题”,用户无法输入。我发现该问题与 key 相关并已修复,但是,这表明可能会出现一些问题,并且由于此阻塞,用户无法完成。我希望能
我无法弄清楚这两个流行插件中的哪一个在 Sublime 3 环境中的自动完成功能中运行得更好。究竟有什么区别? 此外,我想知道他们是否可以在不搞砸的情况下正常工作。你能帮我解决这个问题吗? 可以找到插
我显然遗漏了一些东西,但是当我尝试将自动完成添加到文本框时,我不断收到此消息:.autocomplete 不是函数 _布局(仅头部): @ViewBag.Title - My ASP.NET
是否有一种标准方法可以使用 ElasticSearch 为小字段(例如地名)实现逐字符输入自动完成。 (在撰写本文时,可以通过搜索进行大量讨论,但似乎没有什么是确定的。(另外,我看到有人谈论 Apac
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 3 年前。
我正在使用 rails3-jquery-autocomplete gem 来自动完成用户名,搜索属性是 lastname 但我想显示全名作为显示值。这是我的 Controller 中的内容 autoc
我有一个 jQuery 自动完成插件,当我复制/粘贴到它时,它不会触发。有什么办法让它工作吗? 最佳答案 $("#ID").bind("paste", function () { setTim
我有 2 个自动完成 UITextField这将在输入文本时触发表格 View 。其中一个我正在使用MVPlaceSearchTextField .我使用 this 自定义构建的另一个. 当我输入 t
我在一个页面上有多个自动完成。 当我对所有文本字段使用 jQuery UI AutoComplete 时,它会添加表单的动态选择列表 Entry 1 有一个 CSS 样式,ui-au
我在 Google Places API Web 服务中使用 Place Autocomplete,以下 API 调用工作正常: https://maps.googleapis.com/maps/ap
我已经在 angular 5 项目上安装了primeng。 我正在使用 p-autoComplete 组件,但现在发生此错误。 我应该如何解决这个错误? 这是我的源代码。 Basic 最佳答案 通常
我不断出现这个错误: “无效的 DOM 属性 autocomplete 。您是说 autoComplete 吗?” 当我在 上编译我的 React 项目时谷歌浏览器 . 当我尝试在 上编译代码时火狐
我想创建一个动态自动完成输入,可以使用 metroui 进行更新和它类似 jquery m4q 。基于on its documentation ,我需要在input标签中设置data-autocomp
我有两个 下拉菜单。我想根据第一个下拉列表的选择更新第二个下拉列表的搜索列表。 这是一个准备好的非工作插件:http://plnkr.co/edit/GxQujjAcxYdawlANJd9O?p=pr
我们有一个标准的地址表格(街道 1、街道 2、城市、州、邮政编码、国家/地区)。 当我在 Street 1 添加 Google Places Autocomplete API 的代码时,它会在加载页面
我有 md-autocomplete : {{item.name}} :: {{item.type}} 带指令:ng-enter . 我的目标:当用户按下 En
我正在为一家医院创建一个动态表单。我在这里遇到数据自动完成的问题。问题是在将 json 数组更新为 data-autocomplete=' ' 后,它没有更新 data-autocomplete='
我是一名优秀的程序员,十分优秀!