Core & editable: ensure table initialized before using updateCell. See #1099

This commit is contained in:
Rob Garrison 2015-12-10 23:03:34 -06:00
parent aa79c1d4a1
commit 5494d79953
3 changed files with 21 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -1219,6 +1219,12 @@
}, },
updateCell : function( c, cell, resort, callback ) { updateCell : function( c, cell, resort, callback ) {
if ( ts.isEmptyObject( c.cache ) ) {
// empty table, do an update instead - fixes #1099
ts.updateHeader( c );
ts.commonUpdate( c, resort, callback );
return;
}
c.table.isUpdating = true; c.table.isUpdating = true;
c.$table.find( c.selectorRemove ).remove(); c.$table.find( c.selectorRemove ).remove();
// get position from the dom // get position from the dom

View File

@ -222,17 +222,20 @@
.data( 'before', valid ) .data( 'before', valid )
.data( 'original', valid ) .data( 'original', valid )
.trigger( 'change' ); .trigger( 'change' );
$.tablesorter.updateCell( c, $this.closest( 'td' ), false, function() { // prevent error if table was destroyed - see #1099
if ( wo.editable_autoResort ) { if ( c.table.hasInitialized ) {
setTimeout( function() { $.tablesorter.updateCell( c, $this.closest( 'td' ), false, function() {
$.tablesorter.sortOn( c, c.sortList, function() { if ( wo.editable_autoResort ) {
tse.editComplete( c, wo, c.$table.data( 'contentFocused' ), true ); setTimeout( function() {
}, true ); $.tablesorter.sortOn( c, c.sortList, function() {
}, 10 ); tse.editComplete( c, wo, c.$table.data( 'contentFocused' ), true );
} else { }, true );
tse.editComplete( c, wo, c.$table.data( 'contentFocused' ) ); }, 10 );
} } else {
}); tse.editComplete( c, wo, c.$table.data( 'contentFocused' ) );
}
});
}
return false; return false;
} }
} else if ( !valid && e.type !== 'keydown' ) { } else if ( !valid && e.type !== 'keydown' ) {