使用Bootstrap的suggest下拉插件
前端代码
/*html代码*/
<input type="text" class="form-control search_ul" id="cateCode_search" name="cateCode">
<ul class="dropdown-menu dropdown-menu-right search_ul" role="menu">
</ul> /*js代码*/
<!-- 引入jQuery -->
<script src="/${appName}/commons/jslib/hplus/js/jquery.min.js"></script>
<!-- 引入bootstrap -->
<script type="text/javascript" src="/${appName}/commons/jslib/hplus/js/bootstrap.min.js"></script>
<!-- 引入suggest -->
<script type="text/javascript" src="/${appName}/commons/jslib/hplus/js/plugins/suggest/bootstrap-suggest.min.js"></script> $("#cateCode_search").bsSuggest('init', {
clearable: true,
url: "/${appName}/manager/CommonController/getAllCate",
showBtn: false,
idField: "cate_code", //id字段
keyField: "cate_name", //key字段
effectiveFields: ["cate_code","cate_name"], //显示的有效字段
effectiveFieldsAlias: {"cate_name":"类别","cate_code":"编号"}, //字段别名,title显示
}).on("onSetSelectValue",function(e, keyword) { //选择时
cate_code_add = keyword.id;
console.info(cate_code_add);
}).on("onUnsetSelectValue",function(e) {
cate_code_add = '';
}); /*样式,在body最后加入一个js*/
$(function(){
$('.search_ul').css({left:'0px',width:'100%'});
});
数据格式
{"value":[{"field1":"val1","field2":"val2","field3":val3}]}
后台
/**
* 查询所有类别
* */
@RequestMapping(value = "/getAllCate")
@ResponseBody
public Map getAllCate(HttpServletRequest request, HttpServletResponse response){
List<Concategory> result = commonService.getAllCate(); //获取category集合
Map map = new HashMap();
map.put("value",result); //将list放入key为value的map中
return map; //返回格式{"value":[{"cate_code":"cate1","cate_name":"用餐","cate_level":1}]}
}
使用Bootstrap的suggest下拉插件的更多相关文章
- Bootstrap Search Suggest 下拉框模糊查询
源码地址:https://github.com/lzwme/bootstrap-suggest-plugin 有时间会完善!暂时有点忙!
- jQuery超酷下拉插件6种效果演示
原始的下拉框很丑啦, 给大家一款jQuery超酷下拉插件6种效果 效果预览 下载地址 实例代码 <div class="container"> <section ...
- Bootstrap系列 -- 24. 下拉菜单基本用法
在使用Bootstrap框架的下拉菜单时,必须调用Bootstrap框架提供的bootstrap.js文件.当然,如果你使用的是未编译版本,在js文件夹下你能找到一个名为“dropdown.js”的文 ...
- 实现bootstrap的dropdown-menu(下拉菜单)点击后不关闭的方法 (转)
实现bootstrap的dropdown-menu(下拉菜单)点击后不关闭的方法 问题描述,在下拉菜单中,添加其他元素,例如,原文作者所述的<a>和我自己实际用到的<input> ...
- 模块:(日期选择)jquery、bootstrap实现日期下拉选择+bootstrap jquery UI自带动画的日期选择器
一:jquery.bootstrap实现日期下拉选择 点击文本框弹出窗口 弹窗显示日期时间选择下拉 年份取当前年份的前后各5年 天数随年份和月份的变化而变化 点击保存,文本框中显示选中的日期 代码部分 ...
- bootstrap 多级联动下拉框
<!DOCTYPE HTML> <html lang="zh-CN"> <head> <meta charset="UTF-8& ...
- 【Bootstrap】 bootstrap-select2下拉菜单插件
这次开发了个小TRS系统,虽然是很小,但是作为初心者,第一次用到了很多看起来洋气使用起来有相对简单的各种前端(主要是和bootstrap配合使用)组件.包括bootstrap-select2,boot ...
- Bootstrap系列 -- 27. 下拉菜单对齐方式
Bootstrap框架中下拉菜单默认是左对齐,如果你想让下拉菜单相对于父容器右对齐时,可以在“dropdown-menu”上添加一个“pull-right”或者“dropdown-menu-right ...
- Bootstrap系列 -- 26. 下拉菜单标题
Bootstrap下拉菜单中使用 dropdown-header 来显示菜单标题,和上一篇说道的分割线一样 <div class="dropdown"> <but ...
随机推荐
- LinearLayout学习笔记
线性布局分两种,分别是水平线性布局和垂直线性布局,对应设置为android:orientation="horizontal"/"vertical". Linea ...
- Zabbix邮件告警提示Couldn't resolve host name解决办法
zabbix设置好邮件告警,当有触发时邮件未发送 查看zabbix server日志,提示不能连接邮件发送服务器,但是ping是可以通的
- 牛客网多校赛第七场A--Minimum Cost Perfect Matching【位运算】【规律】
链接:https://www.nowcoder.com/acm/contest/145/A 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524 ...
- Oracle卸载之linux快速卸载rac脚本-一键卸载
#!/bin/bash#Usage:Log on as the superuser('root') on node1,node2 cd /u01/app/11.2.0/grid/bin./crsctl ...
- nginx详解之语法规则
1.location [=|~|~*|^~] /uri/ { … } location = / { # 精确匹配 / ,主机名后面不能带任何字符串 [ configuration A ] ...
- Flink简介及使用
一.Flink概述 官网:https://flink.apache.org/ mapreduce-->maxcompute HBase-->部门 quickBI DataV Hive--& ...
- Python开发【模块】:torndb
Torndb模块 概要:torndb是一个轻量级的基于MySQLdb封装的一个模块,其是tornado框架的一部分.其项目主页为:https://github.com/bdarnell/torndb ...
- 12.GIT多人协作
当你从远程仓库克隆时,实际上Git自动把本地的master分支和远程的master分支对应起来了,并且,远程仓库的默认名称是origin. 查看远程库的信息 $ git remote origin $ ...
- Mirror--使用证书配置镜像模板
--==================================================================--该文档主要用于内部配置模板--场景:--主服务器:192.1 ...
- Struts2表单数据接收方式
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/sunshoupo211/article/details/30249239 1.将Action类作 ...