Angularjs jQuery 数据表添加处理事件
Angularjs jQuery datatables add processing event
我使用 Angular 数据表模块。 https://github.com/l-lin/angular-datatables
我尝试添加 processing.dt
事件,但它不起作用。
这是基础的原始代码api
https://datatables.net/reference/event/processing
$('#example')
.on( 'processing.dt', function ( e, settings, processing ) {
$('#processingIndicator').css( 'display', processing ? 'block' : 'none' );
} )
.dataTable();
这是我未处理的代码
.withOption('processing.dt', function( e, settings, processing){
console.log(processing);
$scope.loading = processing;
}) .withOption('initComplete', function(){
$scope.loading = false;
})
在处理angular数据table时使用dataTables事件没有区别。如果你有 table
<table datatable dt-options="dtOptions" dt-columns="dtColumns" id="example">
然后这有效[http://plnkr.co/edit/hBDjR9ytD0hK6YgwrgMd?p=preview]
$('#example').on('processing.dt', function() {
console.log('processiong.dt');
})
这有效[http://plnkr.co/edit/zKYyrneXl2YudNTXZkXv?p=preview]
angular.element('#example').on('processing.dt', function() {
console.log('processiong.dt');
})
如果您使用 dtInstance
,您甚至可以将事件侦听器附加到它(这里等待 dtInstance
被初始化,然后附加一个 order.dt
处理程序 [ http://plnkr.co/edit/DJa1xwzxArrWhplDY278?p=preview ]) :
$scope.dtInstance = {}
$scope.$watch('dtInstance', function() {
if ($scope.dtInstance.DataTable) {
$scope.dtInstance.DataTable.on('order.dt', function() {
console.log('order.dt')
})
}
})
只是为了证明没有特定的 "angular datatables" 处理事件的方式,它基本上是完全相同的 - 你只是有更多的选择,因为你也有 angular.element()
方式并且可以处理特殊的 dtInstance
对象。
我使用 Angular 数据表模块。 https://github.com/l-lin/angular-datatables
我尝试添加 processing.dt
事件,但它不起作用。
这是基础的原始代码api https://datatables.net/reference/event/processing
$('#example')
.on( 'processing.dt', function ( e, settings, processing ) {
$('#processingIndicator').css( 'display', processing ? 'block' : 'none' );
} )
.dataTable();
这是我未处理的代码
.withOption('processing.dt', function( e, settings, processing){
console.log(processing);
$scope.loading = processing;
}) .withOption('initComplete', function(){
$scope.loading = false;
})
在处理angular数据table时使用dataTables事件没有区别。如果你有 table
<table datatable dt-options="dtOptions" dt-columns="dtColumns" id="example">
然后这有效[http://plnkr.co/edit/hBDjR9ytD0hK6YgwrgMd?p=preview]
$('#example').on('processing.dt', function() {
console.log('processiong.dt');
})
这有效[http://plnkr.co/edit/zKYyrneXl2YudNTXZkXv?p=preview]
angular.element('#example').on('processing.dt', function() {
console.log('processiong.dt');
})
如果您使用 dtInstance
,您甚至可以将事件侦听器附加到它(这里等待 dtInstance
被初始化,然后附加一个 order.dt
处理程序 [ http://plnkr.co/edit/DJa1xwzxArrWhplDY278?p=preview ]) :
$scope.dtInstance = {}
$scope.$watch('dtInstance', function() {
if ($scope.dtInstance.DataTable) {
$scope.dtInstance.DataTable.on('order.dt', function() {
console.log('order.dt')
})
}
})
只是为了证明没有特定的 "angular datatables" 处理事件的方式,它基本上是完全相同的 - 你只是有更多的选择,因为你也有 angular.element()
方式并且可以处理特殊的 dtInstance
对象。