diff --git a/demo/app.js b/demo/app.js index 5890f627e..75fbc983f 100644 --- a/demo/app.js +++ b/demo/app.js @@ -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 }); }); }); diff --git a/demo/usages.js b/demo/usages.js index f780db1ec..80f5a5ce0 100644 --- a/demo/usages.js +++ b/demo/usages.js @@ -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(); + } }] }); diff --git a/demo/withPlugins/withFixedHeader.html b/demo/withPlugins/withFixedHeader.html index f46c99c1a..12dd36f69 100644 --- a/demo/withPlugins/withFixedHeader.html +++ b/demo/withPlugins/withFixedHeader.html @@ -12,6 +12,36 @@

 With the DataTables +

+  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. +

+

+ For example, if you are using Angular ui-router, you can + add an onExit callback like this: +

+
+
+$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(); + } +}); +
+