Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
fixed the logic for calculating the nth-child selector. Addresses #5093
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Jehl committed Nov 2, 2012
1 parent e4f34b7 commit be75fa2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion js/widgets/jquery.mobile.table.js
Expand Up @@ -40,6 +40,9 @@ $.widget( "mobile.table", $.mobile.widget, {

var span = parseInt( $( this ).attr( "colspan" ), 10 ),
sel = ":nth-child(" + ( coltally + 1 ) + ")";

$( this )
.jqmData( "colstart", coltally + 1 );

if( span ){
for( var j = 0; j < span - 1; j++ ){
Expand All @@ -49,7 +52,8 @@ $.widget( "mobile.table", $.mobile.widget, {
}

// Store "cells" data on header as a reference to all cells in the same column as this TH
$( this ).jqmData( "cells", self.element.find( "tr" ).not( trs.eq(0) ).not( this ).children( sel ) );
$( this )
.jqmData( "cells", self.element.find( "tr" ).not( trs.eq(0) ).not( this ).children( sel ) );

coltally++;

Expand Down
6 changes: 4 additions & 2 deletions js/widgets/jquery.mobile.table.reflow.js
Expand Up @@ -38,6 +38,7 @@ $( document ).delegate( ":jqmData(role='table')", "tablecreate", function() {
// create the hide/show toggles
reverseHeaders.each(function(i){
var $cells = $( this ).jqmData( "cells" ),
colstart = $( this ).jqmData( "colstart" ),
hierarchyClass = $cells.not( this ).filter( "thead th" ).length && " ui-table-cell-label-top",
text = $(this).text();

Expand All @@ -47,8 +48,9 @@ $( document ).delegate( ":jqmData(role='table')", "tablecreate", function() {
var iteration = parseInt( $( this ).attr( "colspan" ), 10 ),
filter = "";

if( iteration ){
filter = "td:nth-child("+ iteration +"n)";
if( iteration ){
filter = "td:nth-child("+ iteration +"n + " + ( colstart ) +")";
console.log("td:nth-child("+ iteration +"n + " + ( colstart ) +")")
}
$cells.filter( filter ).prepend( "<b class='" + o.classes.cellLabels + hierarchyClass + "'>" + text + "</b>" );
}
Expand Down

0 comments on commit be75fa2

Please sign in to comment.