Skip to content

Commit

Permalink
Add additional doc on fixedHeader plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
l-lin committed Jan 23, 2015
1 parent f4fcf7a commit b33bc8c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 2 additions & 1 deletion demo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function routerConfig($stateProvider, $urlRouterProvider, USAGES) {
templateUrl: 'demo/' + key + '/' + usage.name + '.html',
controller: function($rootScope) {
$rootScope.$broadcast('event:changeView', usage.name);
}
},
onExit: usage.onExit
});
});
});
Expand Down
8 changes: 7 additions & 1 deletion demo/usages.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ angular.module('showcase.usages', ['ngResource'])
label: 'With Fixed Columns'
}, {
name: 'withFixedHeader',
label: 'With Fixed Header'
label: 'With Fixed Header',
onExit: function() {
var fixedHeaderEle = document.getElementsByClassName('fixedHeader');
angular.element(fixedHeaderEle).remove();
var fixedFooterEle = document.getElementsByClassName('fixedFooter');
angular.element(fixedFooterEle).remove();
}
}]
});
30 changes: 30 additions & 0 deletions demo/withPlugins/withFixedHeader.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ <h1><i class="fa fa-play"></i>&nbsp;With the DataTables <a href="https://datatab
<p>
You also need to add the dependency <code>datatables.fixedheader</code> to your Angular app.
</p>
<div class="api alert alert-danger">
<p>
<i class="fa fa-warning"></i>&nbsp;Beware when using routers. It seems that the header and the footer stay
in your DOM even when you change your application state. So you will need to tweek your code to remove them
when exiting the state.
</p>
<p>
For example, if you are using <a href="https://github.com/angular-ui/ui-router">Angular ui-router</a>, you can
add an <code>onExit</code> callback like this:
</p>
<br />
<div hljs>
$stateProvider.state("contacts", {
templateUrl: 'somewhereInDaSpace',
controller: function($scope, title){
// Do your stuff
},
onEnter: function(title){
// Do your stuff
},
onExit: function(){
// Remove the DataTables FixedHeader plugin's headers and footers
var fixedHeaderEle = document.getElementsByClassName('fixedHeader');
angular.element(fixedHeaderEle).remove();
var fixedFooterEle = document.getElementsByClassName('fixedFooter');
angular.element(fixedFooterEle).remove();
}
});
</div>
</div>
</section>
<section class="showcase">
<div ng-controller="WithFixedHeaderCtrl as showCase">
Expand Down

0 comments on commit b33bc8c

Please sign in to comment.