最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用contextMenu插件实现Bootstrap table弹出右键菜单
时间:2017-04-20 编辑:简简单单 来源:一聚教程网
如今Bootstrap这个前端框架已被许多人接受并应用在不同的项目中,其中“开发高效,设备兼容”的特点表现得非常明显。再加上它默认的美观的UI组件,简直就是很多前端的大爱啊!!! 今天在这里跟大家分享Bootstrap table弹出右键菜单的实现方法。
最近遇到有一个需求,需要在Bootstrap table上使用右键。网上搜了半天没有找到,最后发现Bootstrap table不支持右键(官方文档给出的答案 https://github.com/wenzhixin/bootstrap-table/issues/241 )。
本文介绍使用contextMenu插件实现Bootstrap table右键功能。
代码(test.html):
代码如下 | 复制代码 |
$('#item_table').bootstrapTable({ columns: [{ field:'id', title:'Item ID' }, { field:'name', title:'Item Name' }, { field:'price', title:'Item Price' }], data: [{ id: 1, name:'Item 1', price:'$1' }, { id: 2, name:'Item 2', price:'$2' }] }); $.contextMenu({ // define which elements trigger this menu selector:"#item_table td", // define the elements of the menu items: { foo: {name:"Foo", callback:function(key, opt){ alert("Foo!"); }}, bar: {name:"Bar", callback:function(key, opt){ alert("Bar!") }} } // there's more, have a look at the demos and docs... }); |
效果图:
相关文章
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31
- HTML中空格表示的意义 10-31
- html area标签解读 10-31
- html使用表单标签实现注册页面代码展示 10-31
- 使用HTML截图并保存为本地图片的代码展示 10-31