Skip to content

Commit

Permalink
"Show more" sort bug (#2416)
Browse files Browse the repository at this point in the history
* Update _notes.html.erb render "Show # More" as footer - separately from rows

* Update grid.js to detach table footer before sorting and (re)append it after sorting
  • Loading branch information
adrian-lara authored and jywarren committed Feb 27, 2018
1 parent ad20465 commit 47b3004
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/assets/javascripts/grids.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function sortGrid(type, selector, headerLink) {
headerLink = $(headerLink),
desc = headerLink.hasClass('desc'),
header = table.find('tr:first').detach(),
footer = table.find('tfoot').detach(),
rows = table.find('tr').detach();

rows = rows.sort(function(a, b){
Expand Down Expand Up @@ -39,6 +40,7 @@ function sortGrid(type, selector, headerLink) {

table.html(rows);
table.prepend(header);
table.append(footer);

console.log('rows')
rows.each(function(row) {
Expand Down
16 changes: 8 additions & 8 deletions app/views/grids/_notes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
<% end %>
<% end %>
</tr>
<% if index == 9 %>
<tr class="show-all">
<td><a>Show <%= nodes.length - 10 %> more <b class="caret"></b></a></td>
<td></td>
<td></td>
<td></td>
</tr>
<% end %>
<% end %>
<% if nodes.count > 9 %>
<tfoot>
<th class="show-all"><a>Show <%= nodes.length - 10 %> more <b class="caret"></b></a></th>
<th></th>
<th></th>
<th></th>
</tfoot>
<% end %>
</table>

Expand Down

0 comments on commit 47b3004

Please sign in to comment.