Ensure updateRow & not update is triggered. See issue #217

This commit is contained in:
Mottie 2013-12-19 11:36:41 -06:00
parent e3ae84a1e9
commit c4dceff34e
3 changed files with 8 additions and 6 deletions

View File

@ -333,7 +333,7 @@
fixHeight(table, p); fixHeight(table, p);
// apply widgets after table has rendered // apply widgets after table has rendered
$t.trigger('applyWidgets'); $t.trigger('applyWidgets');
$t.trigger('update', [false, function(){ $t.trigger('updateRow', [false, function(){
if (p.initialized) { if (p.initialized) {
$t.trigger('updateComplete'); $t.trigger('updateComplete');
$t.trigger('pagerChange', p); $t.trigger('pagerChange', p);
@ -564,7 +564,7 @@
pg.val(p.size); // set page size pg.val(p.size); // set page size
p.totalPages = Math.ceil( Math.min( p.totalPages, p.filteredPages ) / p.size ); p.totalPages = Math.ceil( Math.min( p.totalPages, p.filteredPages ) / p.size );
if ( triggered ) { if ( triggered ) {
$(table).trigger('update'); $(table).trigger('updateRow');
setPageSize(table, p.size, p); setPageSize(table, p.size, p);
hideRowsSetup(table, p); hideRowsSetup(table, p);
fixHeight(table, p); fixHeight(table, p);

View File

@ -3243,7 +3243,7 @@ $("table").trigger("sortReset");</pre></div>
<tr id="update"> <tr id="update">
<td><a href="#" class="permalink">update</a> / <a href="#" class="permalink">updateRow</a></td> <td><a href="#" class="permalink">update</a> / <a href="#" class="permalink">updateRow</a></td>
<td>Update the <code>tbody</code>'s stored data (<code>update</code> &amp; <code>updateRow</code> do exactly the same thing) <td>Update the <code>tbody</code>'s stored data (<code>update</code> &amp; <code>updateRow</code> do exactly the same thing)
<div class="collapsible"> <div class="collapsible"><br>
<pre class="prettyprint lang-javascript">// Add new content <pre class="prettyprint lang-javascript">// Add new content
$("table tbody").append(html); $("table tbody").append(html);
@ -3264,7 +3264,9 @@ $("table").trigger("update", [resort, callback]);
var sorting = [[2,1],[0,0]]; var sorting = [[2,1],[0,0]];
$("table") $("table")
.trigger("update", [ false ]) .trigger("update", [ false ])
.trigger("sorton", [sorting]);</pre></div> .trigger("sorton", [sorting]);</pre>
Note: <code>updateRow</code> was added to work around the issue of using jQuery with the Prototype library. Triggering an "update" would make Prototype clear the tbody; Please see <a href="https://github.com/Mottie/tablesorter/issues/217">issue #217</a> for more details.
</div>
</td> </td>
<td><a href="example-ajax.html">Example</a></td> <td><a href="example-ajax.html">Example</a></td>
</tr> </tr>

View File

@ -519,7 +519,7 @@ tsp = ts.pager = {
tsp.fixHeight(table, c); tsp.fixHeight(table, c);
// apply widgets after table has rendered // apply widgets after table has rendered
$t.trigger('applyWidgets'); $t.trigger('applyWidgets');
$t.trigger('update', [false, function(){ $t.trigger('updateRow', [false, function(){
if (p.initialized) { if (p.initialized) {
$t.trigger('updateComplete'); $t.trigger('updateComplete');
$t.trigger('pagerChange', c); $t.trigger('pagerChange', c);
@ -762,7 +762,7 @@ tsp = ts.pager = {
p.totalPages = Math.ceil( Math.min( p.totalPages, p.filteredPages ) / p.size ); p.totalPages = Math.ceil( Math.min( p.totalPages, p.filteredPages ) / p.size );
c.$table.removeClass('pagerDisabled'); c.$table.removeClass('pagerDisabled');
if ( triggered ) { if ( triggered ) {
c.$table.trigger('update'); c.$table.trigger('updateRow');
tsp.setPageSize(table, p.size, c); tsp.setPageSize(table, p.size, c);
tsp.hideRowsSetup(table, c); tsp.hideRowsSetup(table, c);
tsp.fixHeight(table, c); tsp.fixHeight(table, c);