JqueryUI 自动完成结果列表与 jquery Mobile 一起使用
我想将自动完成源的结果列表推送到 jquery mobile 的 ul 元素内,我怀疑 open 事件可以在这里帮助我。如果你们中的任何人取得了这样的成就,将对我有很大帮助(jquery 新手)
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function () {
$("#searchText").autocomplete({
source: '/CRM/SearchResult',
minLength: 1,
appendTo: "#searchResultList",
open: function () {
}
});
});
</script>
<input type="text" name="searchText" id="searchText" />
<ul data-role="listview" id="searchResultList">
</ul>
I want to push result list of autocomplete source inside ul element of jquery mobile, I suspect open event can help me out here. If any of you have achieved something like this, would be great help to me (new to jquery)
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function () {
$("#searchText").autocomplete({
source: '/CRM/SearchResult',
minLength: 1,
appendTo: "#searchResultList",
open: function () {
}
});
});
</script>
<input type="text" name="searchText" id="searchText" />
<ul data-role="listview" id="searchResultList">
</ul>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我通过在 Firebug 的帮助下提取 jquermobile 标签的准系统来实现所需的输出(我不确定这是否是个好主意,但它对我来说非常有用):
I achieved the desired output by extracting barebones of jquermobile tags with the help of Firebug (i am not sure if this was good idea, but it is working great for me):
你确实可以做到这一点。您需要为
open
提供回调函数,一旦打开自动完成菜单,就会触发该回调函数。因此,您的函数应该执行以下操作。首先,获取无序列表容器的句柄:...然后迭代您的搜索结果(
$.each()
或类似的操作应该这样做)。对于每个结果值,附加
一个列表项到您的ul
:...最后您需要刷新列表,以便 jQM 正确更新 UI:
You can indeed do this. You need to provide
open
with a callback function, and this ill be triggered once the autocomplete menu is opened. Your function should therefore do something as follows. First, get a handle on your unordered list container:... then iterate your search results (
$.each()
or similar should do). For each result value,append
a list item to yourul
:... and then finally you will need to refresh the list so that jQM updates the UI properly:
如果你仍然感兴趣但我怀疑你是
In case you're still interested but I doubt you are