tagsinput和typeahead生成标签
来源:互联网 发布:mysql over 函数 编辑:程序博客网 时间:2024/06/02 07:07
bootstrap-tagsinput是一款插件,用于页面tag标签生成。
它支持自己手动输入,同时也能在ajax基础上智能填充输入框内容。
一般的功能,官网上有介绍。不过对于自动填充这块,需要详细说明一下。
效果图
require
bootstrap-tagsinput-angular.js
bootstrap-tagsinput.js
bootstrap-tagsinput.css
bootstrap3-typeahead.min.js(注意,这里需要的这个typeahead和官网上的有所区别。官网的存在问题!)
html
<div class="col-md-8 col-md-offset-2"> <input id="tags" type="text" class="form-control" placeholder="请输入标签" data-role="tagsinput"/></div><script th:inline="javascript"> $('#tags').tagsinput({ maxTags: 5, //表示ajax接收后数据对应格式 itemValue: 'id', itemText: 'name', typeahead: { displayKey: 'name', source: function(query) { return $.get('/tag/list', {query: query}); }, //清除input上多出来的一条无效数据 afterSelect: function() { this.$element[0].value = ''; } }, freeInput: true });</script>
java
这里用的是springboot
@Controller@RequestMapping("/tag")public class TagController { @RequestMapping(value = "/list", method = RequestMethod.GET) public @ResponseBody List<Tag> getTagsList(@RequestParam String query) { return new TagServiceImpl().getTagsByName(query); }}
数据格式
返回的格式如下,前台只用到了id和name。
也可以这么返回:[‘java’, ‘php’, ‘c++’]。只要封装成一个List即可。
[ { "id": "001", "createdId": null, "createdName": null, "createdTime": null, "name": "java" }, { "id": "002", "createdId": null, "createdName": null, "createdTime": null, "name": "php" }, { "id": "003", "createdId": null, "createdName": null, "createdTime": null, "name": "c++" }]
阅读全文
1 0
- tagsinput和typeahead生成标签
- 【NSBD】——Jquery tagsinput标签
- Bootstrap框架----标签Tag输入用法--Bootstrap-tagsinput
- Auto Complete -- Typeahead 和DateRangePicker
- Auto Complete -- Typeahead 和DateRangePicker
- jQuery TagsInput
- 动态生成标签和删除
- Notes9.0中Typeahead 同时显示服务器和本地联系人
- 网页中模糊查询js插件autocomplete和typeahead
- typeahead模糊搜索查询-结合bootstrap和jquery
- TYPEAHEAD helloworld
- typeahead/autocomplete
- bootstrap-tagsinput的使用简介
- bootstrap-tagsinput插件展示关键字
- 由Typeahead想到的搜索的本质,和OO和数据库是统一的
- s:tree和s:treenode标签生成静态树
- Twitter Typeahead plugin Example
- bootstrap中的typeahead
- linux 网络状态监控 netstat
- 使用Spring的@Scheduled实现定时任务
- 动态库的搜索路径搜索的先后顺序
- iOS ARKit是什么。ARKit介绍。ARKit类简介。
- 面向对象c++之继承
- tagsinput和typeahead生成标签
- 我的常用命令--find命令
- ubuntu LAMP 配置多虚拟主机站点
- Window10下docker配置PHP开发环境
- SQL Server基础之存储过程
- centos7 配置mariadb10 主从数据库
- 工程依赖bouncycastle,Tomcat抛出异常 StackOverflowError
- ECS实例RAM角色实践
- web测试要点