单击两次时,Javascript Jtable关闭子表
Javascript Jtable Close Child Table when clicked twice
我有一个带有一些子表的Javascript Jtable。我想做的是在第二次单击行标题时关闭子表。
所以我设置了一些全局变量:
var NotesOpen = false;
var HistoryOpen = false;
var ElementsOpen = false;
因此,在f.ex Notes子表i上,单击函数如下所示:
$img.click(function () {
if (NotesOpen == true) {
console.log($(this).closest('tr').next('tr').find(':button').html());
$(this).closest('tr').next('tr').find(':button').click();
$(this).closest('tr').next('tr').find(':button').trigger('click');
$(this).closest('tr').next('tr').find('.jtable-close-button').click();
}
NotesOpen = true;
我可以看到调试线路。它找到了正确的行,因为它在控制台窗口中说是<span>Close</span>
。如果我只检查$(this).closest('tr').next('tr').html()
,我可以看到它在正确的行上。
然而,当我尝试触发点击事件时,我只得到一个错误:Uncaught Error: cannot call methods on jtable prior to initialization; attempted to call method 'destroy' jquery-2.1.1.js:250
此代码有助于通过单击图像图标打开或关闭子表。
//CHILD TABLE DEFINITION FOR "PHONE NUMBERS"
Phones: {
title: '',
width: '5%',
sorting: false,
edit: false,
create: false,
display: function (studentData) {
var $img = $('<img src="/Content/images/Misc/phone.png" title="Edit phone numbers" />'), //Create an image that will be used to open child table
parentTable = $("#StudentTableContainer");
//Open | Close child table when user clicks the image
$img.click(function(){
var tr = $(this).parents("tr"),
isChildRowOpen = parentTable.jtable("isChildRowOpen", tr );
if( isChildRowOpen ){
$( parentTable.jtable("getChildRow", tr ) ).slideUp();
return;
}
// some another code
}
}
}
相关文章:
- 为什么不't Javascript对我的输入值进行了一些重新检查
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 将函数的上下文应用于javascript变量
- 使用php或javascript从facebook相册URL中删除多余的部分
- 正在添加'X'按钮,在文本字段旁边使用javascript
- 如何在JavaScript中将字符串转换为函数引用
- 模糊事件的Javascript测试
- Javascript更改图标
- 如何将HTML id分配给元素,以及如何将JavaScript应用于元素
- 如何使用WCF服务和javascript表单post上传.doc文件
- javascript结合了数组和字典
- 这是什么 ==- javascript 运算符
- 从javascript创建一个列表
- 无法在通过jQuery的ajax加载的页面中执行javascript
- JavaScript JTable-具有多个级联列表/下拉列表的Null值
- 将 jQuery/JavaScript 函数应用于 jTable 检索的 SQL 数据
- 动态创建用于jQuery-jTable的多级Javascript对象
- 单击两次时,Javascript Jtable关闭子表
- 使用javascript在JTable中删除记录(仅限客户端)
- 导出jtable excel在javascript上的IE