Permalink
Browse files

fixed the logic for calculating the nth-child selector. Addresses #5093

  • Loading branch information...
Scott Jehl
Scott Jehl committed Nov 2, 2012
1 parent e4f34b7 commit be75fa238f2d970b2e1c2385a0ae15e977b5a9f8
Showing with 9 additions and 3 deletions.
  1. +5 −1 js/widgets/jquery.mobile.table.js
  2. +4 −2 js/widgets/jquery.mobile.table.reflow.js
@@ -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++ ){
@@ -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++;
@@ -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();
@@ -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>" );
}

0 comments on commit be75fa2

Please sign in to comment.