jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了带角度数据表的Jquery onclick事件大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
每当点击一列数据表时,我都必须打开一个链接.这是我的数据表代码,它通过ajax调用获取数据 –

@H_502_11@<table datatable="" dt-options="dtOptions" dt-columns="dtcolumns" class="featuretable row-border compact hover" > <thead > <!--change style of column with css--> <tr> <th class="Header">Feature</th> <th class="Header">ID</th> <th class="Header">Log</th> <th class="Header">LOCATIOn</th> </tr> </thead> </table>

这是我正在尝试的Jquery Code –

@H_502_11@$('.featuretable tbody').on('click','tr',function () { console.log( table.row( this ).data() ); var data = table.row( this ).data(); alert( 'You clicked on '+data[1]+'\'s row' ); } );

css文件读取 –

@H_502_11@.Header { border-bottom: 2px solid #6f7277; padding: 3px 15px; text-align: left; color: #4b4a4a; overflow: hidden; } table.featuretable { table-layout:fixed; width:100%; font-family: @R_801_11423@vetica,Arial,sans-serif; margin-top: 20px; margin-bottom: 20px; border-collapse: collapse; border-spacing: 0; } table.featuretable td,th { border: 1px solid transparent; height: 30px; transition: all 0.3s; overflow: hidden; } table.featuretable th { font-weight: bold; text-align: center; vertical-align: :middle; } table.featuretable td { text-align: center; vertical-align: :middle; } table.featuretable tr:nth-child(even) td { BACkground: #f3f7fb; } table.featuretable tr:nth-child(odd) td { BACkground: #ffffff; }

点击,chrome给出错误“ReferenceError:table is not defined”.有人知道怎么做吗 ?

解决方法

由于您使用的是angular dataTables指令,因此您应该定义一个dTinstance并对其进行处理:

@H_502_11@$scope.dTinstance = {} @H_502_11@<table datatable="" dt-instance="dTinstance" dt-options="dtOptions" dt-columns="dtcolumns" class="featuretable row-border compact hover" >

然后在您的jQuery事件处理程序中,使用dTinstance作为表引用

@H_502_11@$('.featuretable tbody').on('click',function () { var data = $scope.dTinstance.DataTable.row( this ).data(); alert( 'You clicked on '+data[1]+'\'s row' ); } );

大佬总结

以上是大佬教程为你收集整理的带角度数据表的Jquery onclick事件全部内容,希望文章能够帮你解决带角度数据表的Jquery onclick事件所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。