自动补全Typeahead
采用 Typeahead (Bootstrap-3-Typeahead-master)
<script type="text/javascript"
src="/js/plugins/bootstrap3-typeahead.min.js"></script>
<script type="text/javascript">//自动补全
$("#loginInfoDisplay").typeahead({
minLength:3,//最小开始查询的字符个数
items:5,//下拉列表中最多显示的条数
source:function(query,process){//加载数据源
$.ajax({
dataType:"json",
type:"POST",
url:"vedioAuth_autocomplate.do",
data:{str:query},
success:function(data){//这个data就是一个json对象的数组{id:xx,username:xxxx}
if(data && data.length){
process(data);//process就是交给我们获得数据之后用来调用的方法,这个方法执行了,下拉列表就出来了
}
}
});
},
//用来告诉typeahead怎么显示json对象中的内容
displayText:function(item){
return item.username
}
}).change(function(){
var current = $(this).typeahead("getActive");
if(current){
$("#loginInfoValue").val(current.id);
}
});
</script>
<div class="col-sm-6">
<div class="dropdown" id="autocomplate">
<input type="text" class="form-control" id="loginInfoDisplay"
autocomplete="off" /> <input type="text" name="loginInfoValue" id="loginInfoValue"/>
</div>
</div>
=========================================================================
/**
* 用于用户的automcomplate
*/
@RequestMapping("vedioAuth_autocomplate")
@ResponseBody
public List<Map<String, Object>> autoComplate(String str){
return userinfoService.autoComplate(str);
}
=============================================================
@Override
public List<Map<String, Object>> autoComplate(String keyword) { return this.userinfoMapper.autoComplate(keyword);
}
=============================================================
<select id="autoComplate" resultType="hashmap">
SELECT id,username
FROM logininfo WHERE username LIKE concat(#{keyword},'%')
</select>
自动补全Typeahead的更多相关文章
- bootstrap - typeahead自动补全插件
$('#Sale').typeahead({ ajax: { url: '@Url.Action("../Contract/GetSale")', //timeout: 300, ...
- jquery input 搜索自动补全、typeahead.js
最近做个一个功能需要用到自动补全,然后在网上找了很久,踩了各种的坑 最后用typeahead.js这个插件,经过自己的测试完美实现 使用方法:在页面中引入jquery.jquery.typeahead ...
- angular-ui-bootstrap typeahead 智能提示 自动补全 获取焦点不触发问题的解决
项目中有一处使用了angular-ui-bootstrap中的typeahead来实现输入框智能提示语自动化补全的功能,存在一个bug, 即输入文字后,当再次点击文本框,其获取焦点后并不会触发智能提示 ...
- 【Bootstrap】 typeahead自动补全
typeahead 这篇文章记录了我在使用typeahead的一些问题,不是很全,但是基本够用. Bootstrap提供typeahead组件来完成自动补全功能. 两种用法: 直接给标签添加属性 &l ...
- 使用Bootstrap typeahead插件实现搜索框自动补全的配置参数。
示例代码: <input type="text" id="addr"/> <input type="text" hidde ...
- bootstrap3-typeahead 自动补全
很酷的一个自动补全插件 http://twitter.github.io/typeahead.js 在bootstrap中使用typeahead插件,完成自动补全 相关的文档:https://gith ...
- bootstrap-typeahead 自动补全简单的使用教程
参考链接: 参考1 : https://segmentfault.com/a/1190000006036166参考2 : https://blog.csdn.net/u010174173/articl ...
- jQuery 邮箱下拉列表自动补全
综述 我想大家一定见到过,在某个网站填写邮箱的时候,还没有填写完,就会出现一系列下拉列表,帮你自动补全邮箱的功能.现在我们就用jQuery来实现一下. 博主原创代码,如有代码写的不完善的地方还望大家多 ...
- eclipse自动补全的设置
eclipse自动补全的设置 如果你用过Visual Studio的自动补全功能后,再来用eclipse的自动补全功能,相信大家会有些许失望. 但是eclipse其实是非常强大的,eclipse的 ...
随机推荐
- 结合 RunLoop 和 Instrument 定位卡顿
iOS 应用,丝般顺滑的理想情况就是 60FPS (对于 iPad Pro 是 240FPS),即在 16ms 之内完成一次渲染.如果找到在每次渲染花费了多久,究竟做了什么事情,那么就可以进行针对性的 ...
- 大白dmeo (转的)
<!doctype html><html> <head> <meta charset="utf-8"> <title>B ...
- POJ 1067
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> usin ...
- JSON 字符串转换为JavaScript 对象.JSON.parse()和JSON.stringify()
使用 JavaScript 内置函数 JSON.parse() 将字符串转换为 JavaScript 对象: var text = '{ "sites" : [' + '{ &qu ...
- 学习微信小程序及知识占及v-if与v-show差别
注意点: 一.接口调用方式: getOpenid: function () { var that = this; return new Promise(function (resolve, rejec ...
- Python 1行代码实现文本分类(实战笔记),含代码详细说明及运行结果
Python 1行代码实现文本分类(实战笔记),含代码详细说明及运行结果 一.详细说明及代码 tc.py =============================================== ...
- 剑指offer五十四之字符流中第一个不重复的字符
一.题目 请实现一个函数用来找出字符流中第一个只出现一次的字符.例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g".当从该字符流中读出 ...
- EF 一对一、一对多、多对多配置语句小记
数据库实体间的关系无非有这么几种:一对一.一对多.多对多,这些关系在EF框架中分别有不同的创建方式: 1.在"Database First"模式中,这些关系通过SQL语句的方式建立 ...
- 【链表】Linked List Cycle II
题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. ...
- android listview实现点击某个item后使其显示在屏幕顶端
在该listview的点击事件中加入一下代码即可 listView.setSelectionFromTop(position, 0);