Datatables服务器端信息+带2个按钮的静态列
Datatables serverside info + static colum with 2 buttons
我正在努力制作一个带有2个按钮的静态列,这些按钮触发2个带有动态数据的链接。我设法使一个按钮工作,但我不能使另一个。我尝试为每个函数添加一个id,并为每个函数调用不同的函数,但它似乎只适用于$(''#example tbody '')
,而不适用于($(''#customID '')
。
这是我的js:
<script type="text/javascript">
$(document).ready(function() {
var table = $(''#example'').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "app/server_processing.php",
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "<button>Edit</button> <button>Delete</button>"
} ]
} );
$(''#example tbody '').on( ''click'', ''button'', function () {
var data = table.row( $(this).parents(''tr'') ).data();
window.location.href = "index.php?categ=edit&id="+ data[0];
} );
} );
</script>
我修复了
<script type="text/javascript">
$(document).ready(function() {
var table = $(''#example'').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "app/server_processing.php",
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "<button id="edit">Edit</button> <button id="delete">Delete</button>"
} ]
} );
$(''#example tbody '').on( ''click'', ''#edit'', function () {
var data = table.row( $(this).parents(''tr'') ).data();
window.location.href = "index.php?categ=edit&id="+ data[0];
} );
$(''#example tbody '').on( ''click'', ''#delete'', function () {
var data = table.row( $(this).parents(''tr'') ).data();
window.location.href = "index.php?categ=delete&id="+ data[0];
} );
} );
</script>
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 正在添加'X'按钮,在文本字段旁边使用javascript
- 多个单选按钮组相互干扰
- JavaScript下拉菜单-点击按钮并根据所选值重定向到url
- Javascript按钮下拉列表
- jquery试图按名称获取按钮位置
- 漂亮照片图片库中的Facebook赞按钮
- 扩展移相器按钮类不工作
- 通过单击表单中的按钮,在代码生成中使用javascript生成字母数字代码
- 单击按钮以等待单击按钮
- 剑道UI内联编辑:如何在点击其他按钮时隐藏按钮
- 单击按钮后如何逐个调用分区,上一个分区将隐藏
- 如何在HTML按钮中有一个静态onclick参数
- Datatables服务器端信息+带2个按钮的静态列
- 静态html页面的Facebook邀请朋友按钮
- 如何修复动态asp.net页面中静态按钮上的事件处理程序
- 使可移动图像按钮在移动后保持静态
- 如何在静态站点上动态呈现社交分享按钮的元标签
- 带有按钮的鼠标事件:鼠标悬停、onclick、静态
- 喜欢按钮不出现在我的静态网站