Skip to content

Commit b33bc8c

Browse files
committed
Add additional doc on fixedHeader plugin
1 parent f4fcf7a commit b33bc8c

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

demo/app.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ function routerConfig($stateProvider, $urlRouterProvider, USAGES) {
8484
templateUrl: 'demo/' + key + '/' + usage.name + '.html',
8585
controller: function($rootScope) {
8686
$rootScope.$broadcast('event:changeView', usage.name);
87-
}
87+
},
88+
onExit: usage.onExit
8889
});
8990
});
9091
});

demo/usages.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ angular.module('showcase.usages', ['ngResource'])
8989
label: 'With Fixed Columns'
9090
}, {
9191
name: 'withFixedHeader',
92-
label: 'With Fixed Header'
92+
label: 'With Fixed Header',
93+
onExit: function() {
94+
var fixedHeaderEle = document.getElementsByClassName('fixedHeader');
95+
angular.element(fixedHeaderEle).remove();
96+
var fixedFooterEle = document.getElementsByClassName('fixedFooter');
97+
angular.element(fixedFooterEle).remove();
98+
}
9399
}]
94100
});

demo/withPlugins/withFixedHeader.html

+30
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@ <h1><i class="fa fa-play"></i>&nbsp;With the DataTables <a href="https://datatab
1212
<p>
1313
You also need to add the dependency <code>datatables.fixedheader</code> to your Angular app.
1414
</p>
15+
<div class="api alert alert-danger">
16+
<p>
17+
<i class="fa fa-warning"></i>&nbsp;Beware when using routers. It seems that the header and the footer stay
18+
in your DOM even when you change your application state. So you will need to tweek your code to remove them
19+
when exiting the state.
20+
</p>
21+
<p>
22+
For example, if you are using <a href="https://github.com/angular-ui/ui-router">Angular ui-router</a>, you can
23+
add an <code>onExit</code> callback like this:
24+
</p>
25+
<br />
26+
<div hljs>
27+
$stateProvider.state("contacts", {
28+
templateUrl: 'somewhereInDaSpace',
29+
controller: function($scope, title){
30+
// Do your stuff
31+
},
32+
onEnter: function(title){
33+
// Do your stuff
34+
},
35+
onExit: function(){
36+
// Remove the DataTables FixedHeader plugin's headers and footers
37+
var fixedHeaderEle = document.getElementsByClassName('fixedHeader');
38+
angular.element(fixedHeaderEle).remove();
39+
var fixedFooterEle = document.getElementsByClassName('fixedFooter');
40+
angular.element(fixedFooterEle).remove();
41+
}
42+
});
43+
</div>
44+
</div>
1545
</section>
1646
<section class="showcase">
1747
<div ng-controller="WithFixedHeaderCtrl as showCase">

0 commit comments

Comments
 (0)