mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Keep track of initialized widgets & extending widget options. Fixes #330
This commit is contained in:
parent
ab5ceb9e1d
commit
c962a7c20d
@ -886,6 +886,7 @@
|
|||||||
}
|
}
|
||||||
c.$table = $this.addClass(ts.css.table + ' ' + c.tableClass + k);
|
c.$table = $this.addClass(ts.css.table + ' ' + c.tableClass + k);
|
||||||
c.$tbodies = $this.children('tbody:not(.' + c.cssInfoBlock + ')');
|
c.$tbodies = $this.children('tbody:not(.' + c.cssInfoBlock + ')');
|
||||||
|
c.widgetInit = {}; // keep a list of initialized widgets
|
||||||
// build headers
|
// build headers
|
||||||
buildHeaders(table);
|
buildHeaders(table);
|
||||||
// fixate columns if the users supplies the fixedWidth option
|
// fixate columns if the users supplies the fixedWidth option
|
||||||
@ -1220,18 +1221,19 @@
|
|||||||
widgets.sort(function(a, b){
|
widgets.sort(function(a, b){
|
||||||
return a.priority < b.priority ? -1 : a.priority === b.priority ? 0 : 1;
|
return a.priority < b.priority ? -1 : a.priority === b.priority ? 0 : 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
// add/update selected widgets
|
// add/update selected widgets
|
||||||
$.each(widgets, function(i,w){
|
$.each(widgets, function(i,w){
|
||||||
if (w) {
|
if (w) {
|
||||||
if (init) {
|
if (init || !(c.widgetInit[w.id])) {
|
||||||
if (w.hasOwnProperty('options')) {
|
if (w.hasOwnProperty('options')) {
|
||||||
wo = table.config.widgetOptions = $.extend( true, {}, w.options, wo );
|
wo = table.config.widgetOptions = $.extend( true, {}, w.options, wo );
|
||||||
|
c.widgetInit[w.id] = true;
|
||||||
}
|
}
|
||||||
if (w.hasOwnProperty('init')) {
|
if (w.hasOwnProperty('init')) {
|
||||||
w.init(table, w, c, wo);
|
w.init(table, w, c, wo);
|
||||||
}
|
}
|
||||||
} else if (!init && w.hasOwnProperty('format')) {
|
}
|
||||||
|
if (!init && w.hasOwnProperty('format')) {
|
||||||
w.format(table, c, wo, false);
|
w.format(table, c, wo, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1252,7 +1254,10 @@
|
|||||||
for (i = 0; i < l; i++){
|
for (i = 0; i < l; i++){
|
||||||
if ( w[i] && w[i].id && (doAll || $.inArray( w[i].id, cw ) < 0) ) {
|
if ( w[i] && w[i].id && (doAll || $.inArray( w[i].id, cw ) < 0) ) {
|
||||||
if (c.debug) { log( 'Refeshing widgets: Removing ' + w[i].id ); }
|
if (c.debug) { log( 'Refeshing widgets: Removing ' + w[i].id ); }
|
||||||
if (w[i].hasOwnProperty('remove')) { w[i].remove(table, c, c.widgetOptions); }
|
if (w[i].hasOwnProperty('remove')) {
|
||||||
|
w[i].remove(table, c, c.widgetOptions);
|
||||||
|
c.widgetInit[w[i].id] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dontapply !== true) {
|
if (dontapply !== true) {
|
||||||
|
Loading…
Reference in New Issue
Block a user