Skip to content

Commit

Permalink
Add support for changing options dynamically.
Browse files Browse the repository at this point in the history
Motivation: to make this plugin more usable for pages that use responsive
Bootstrap styling. On such pages, it is common for high-resolution views
to use a floating "sticky" nav bar (in which case StickyTableHeaders
needs an offset that's >= 0), while lower-resolution views might make
the nav bar "non-sticky" to conserve screen space. When the viewport
changes, it is necessary to tell StickyTableHeaders to change the
fixedOffset option so that it can account for the varying "stickiness"
of the nav bar. Prior to this commit, the only way to accomplish this
was to destroy the StickyTableHeaders instance and recreate it. I think
this fix is much easier and more efficient!
  • Loading branch information
Jordan Killpack committed May 13, 2013
1 parent c0a4806 commit 548f70d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion js/jquery.stickytableheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@
base.$clonedHeader.css('width', base.$originalHeader.width());
};

base.updateOptions = function(options) {
base.options = $.extend({}, defaults, options);
base.updateWidth();
base.toggleHeaders();
};

// Run initializer
base.init();
}
Expand All @@ -175,7 +181,9 @@
if (instance) {
if (typeof options === "string") {
instance[options].apply(instance);
}
} else {
instance.updateOptions(options);
}
} else if(options !== 'destroy') {
$.data(this, 'plugin_' + name, new Plugin( this, options ));
}
Expand Down
2 changes: 1 addition & 1 deletion js/jquery.stickytableheaders.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 548f70d

Please sign in to comment.