<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Book Excerpt &#8211; Table Manipulation</title>
	<atom:link href="http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation</link>
	<description>Tips, techniques, and tutorials for the jQuery JavaScript library</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:50:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Eddie Foreman</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-81107</link>
		<dc:creator>Eddie Foreman</dc:creator>
		<pubDate>Fri, 23 Jul 2010 16:23:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-81107</guid>
		<description>Hi Guys

I&#039;ve had the book for a while now and have always found it to be a valuable resource.   I&#039;m currently working on a  project which needs pagination, and have used your example in chapter 7.  Works great, except for when the pages first loads.  All tables rows are displayed, and are only updated once the pager links are used.

&lt;pre&gt;&lt;code&gt;
$(document).ready(function() {
  $(&#039;table&#039;).each(function() {
  var currentPage = 0;
  var numPerPage = 5;
  var $table = $(this);
  
//Quick fix to show correct number of rows  when page first loads
  $table.find(&#039;tbody tr&#039;).hide()
  .slice(currentPage * numPerPage,(currentPage + 1) * numPerPage).show();
  
  $table.bind(&#039;repaginate&#039;, function() {
    $table.find(&#039;tbody tr&#039;).hide()
    .slice(currentPage * numPerPage,
      (currentPage + 1) * numPerPage)
    .show();
  });
  var numRows = $table.find(&#039;tbody tr&#039;).length;
  var numPages = Math.ceil(numRows / numPerPage);
  var $pager = $(&#039;&lt;ul class=&quot;pagination&quot;&gt;&lt;/ul&gt;&#039;);
  for (var page = 0; page &lt; numPages; page++) {
    $(&#039;&lt;li&gt;&lt;/li&gt;&#039;).text(page + 1)
    .bind(&#039;click&#039;, {newPage: page}, function(event) {
      currentPage = event.data[&#039;newPage&#039;];
      $table.trigger(&#039;repaginate&#039;);
      $(this).addClass(&#039;active&#039;)
      .siblings().removeClass(&#039;active&#039;);
    }).appendTo($pager).addClass(&#039;clickable&#039;);
  }
  $pager.insertAfter($table)
    .find(&#039;li:first&#039;).addClass(&#039;active&#039;);
  });
});
&lt;/code&gt;&lt;/pre&gt;

Has anyone else had this problem ? As a quick fix, I&#039;ve duplicated a couple of lines to show the correct number of rows on page load.  Was wondering if this is how the book example is suppose to work?

Was also wondering how easy it would be to update the paging so that it also had previous and next buttons.  Any help or pointers on this would be greatly appreciated.

Thanks in advance

Eddie</description>
		<content:encoded><![CDATA[<p>Hi Guys</p>
<p>I&#8217;ve had the book for a while now and have always found it to be a valuable resource.   I&#8217;m currently working on a  project which needs pagination, and have used your example in chapter 7.  Works great, except for when the pages first loads.  All tables rows are displayed, and are only updated once the pager links are used.</p>
<pre><code>
$(document).ready(function() {
  $('table').each(function() {
  var currentPage = 0;
  var numPerPage = 5;
  var $table = $(this);

//Quick fix to show correct number of rows  when page first loads
  $table.find('tbody tr').hide()
  .slice(currentPage * numPerPage,(currentPage + 1) * numPerPage).show();

  $table.bind('repaginate', function() {
    $table.find('tbody tr').hide()
    .slice(currentPage * numPerPage,
      (currentPage + 1) * numPerPage)
    .show();
  });
  var numRows = $table.find('tbody tr').length;
  var numPages = Math.ceil(numRows / numPerPage);
  var $pager = $('&lt;ul class="pagination"&gt;&lt;/ul&gt;');
  for (var page = 0; page &lt; numPages; page++) {
    $(&#039;&lt;li&gt;&lt;/li&gt;').text(page + 1)
    .bind('click', {newPage: page}, function(event) {
      currentPage = event.data['newPage'];
      $table.trigger('repaginate');
      $(this).addClass('active')
      .siblings().removeClass('active');
    }).appendTo($pager).addClass('clickable');
  }
  $pager.insertAfter($table)
    .find('li:first').addClass('active');
  });
});
</code></pre>
<p>Has anyone else had this problem ? As a quick fix, I&#8217;ve duplicated a couple of lines to show the correct number of rows on page load.  Was wondering if this is how the book example is suppose to work?</p>
<p>Was also wondering how easy it would be to update the paging so that it also had previous and next buttons.  Any help or pointers on this would be greatly appreciated.</p>
<p>Thanks in advance</p>
<p>Eddie</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Swedberg</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-77987</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Mon, 03 Aug 2009 14:18:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-77987</guid>
		<description>Hi Sunit, 
You can get updated code samples (for &lt;i&gt;Learning jQuery 1.3&lt;/i&gt;) of all chapters at &lt;a href=&quot;http://book.learningjquery.com/&quot; rel=&quot;nofollow&quot;&gt;book.learningjquery.com&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Hi Sunit,<br />
You can get updated code samples (for <i>Learning jQuery 1.3</i>) of all chapters at <a href="http://book.learningjquery.com/" rel="nofollow">book.learningjquery.com</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sunit Joshi</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-77986</link>
		<dc:creator>Sunit Joshi</dc:creator>
		<pubDate>Mon, 03 Aug 2009 13:59:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-77986</guid>
		<description>I&#039;m trying to get the files for Ch-7 (especially the .css files) where the Table is used with JQuery. It&#039;s not there in the downloadable source code. Any ideas ??

thanks
Sunit</description>
		<content:encoded><![CDATA[<p>I&#8217;m trying to get the files for Ch-7 (especially the .css files) where the Table is used with JQuery. It&#8217;s not there in the downloadable source code. Any ideas ??</p>
<p>thanks<br />
Sunit</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-53224</link>
		<dc:creator>Matthew</dc:creator>
		<pubDate>Thu, 14 Aug 2008 21:32:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-53224</guid>
		<description>Hey guys,

I am trying to do what Corrado Fiore  is doing above, but I would love to see an example with dropdowns instead of div tags to filter.

Ive copied Corrado&#039;s code and used the example table, but it doesnt filter or do anything for me.  

Thank you,

Matthew</description>
		<content:encoded><![CDATA[<p>Hey guys,</p>
<p>I am trying to do what Corrado Fiore  is doing above, but I would love to see an example with dropdowns instead of div tags to filter.</p>
<p>Ive copied Corrado&#8217;s code and used the example table, but it doesnt filter or do anything for me.  </p>
<p>Thank you,</p>
<p>Matthew</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-22996</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Mon, 03 Dec 2007 19:01:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-22996</guid>
		<description>Hi Corrado, 

I&#039;m so glad you like the book! To keep filtering, try replacing these lines ...

&lt;pre&gt;&lt;code&gt;              if ($(&#039;td&#039;, this).filter(&#039;:nth-child(&#039; + (column + 1) + &#039;)&#039;).text() == event.data[&#039;keyword&#039;]) {
                $(this).removeClass(&#039;filtered&#039;).not(&#039;.collapsed&#039;).show();
              }
              else if ($(&#039;th&#039;,this).length == 0) {
                $(this).addClass(&#039;filtered&#039;).hide();
              }&lt;/code&gt;&lt;/pre&gt;

with these ...

&lt;pre&gt;&lt;code&gt;              if ($(&#039;th&#039;,this).length == 0) {
                $(this).addClass(&#039;filtered&#039;).hide();
              }&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hi Corrado, </p>
<p>I&#8217;m so glad you like the book! To keep filtering, try replacing these lines &#8230;</p>
<pre><code>              if ($('td', this).filter(':nth-child(' + (column + 1) + ')').text() == event.data['keyword']) {
                $(this).removeClass('filtered').not('.collapsed').show();
              }
              else if ($('th',this).length == 0) {
                $(this).addClass('filtered').hide();
              }</code></pre>
<p>with these &#8230;</p>
<pre><code>              if ($('th',this).length == 0) {
                $(this).addClass('filtered').hide();
              }</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Corrado Fiore</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-22981</link>
		<dc:creator>Corrado Fiore</dc:creator>
		<pubDate>Mon, 03 Dec 2007 17:02:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-22981</guid>
		<description>Hi,

justed want to say &quot;Thanks!&quot; for such an invaluable book.  I&#039;m one of the many developers to whom Jquery (and your book) opened the doors of rich client scripting.

That said, I have a little question about table filtering.  I was able to set up filtering for my table using some &lt;select&gt;, using the following code:

&lt;pre&gt;&lt;code&gt;$(document).ready(function() {
  $(&#039;table.filterable&#039;).each(function() {
    var $table = $(this);
    $table.find(&#039;th&#039;).each(function (column) {
      if ($(this).is(&#039;.filter-column&#039;)) {
        var $filters = $(&#039;&lt;select class=&quot;filters&quot;&gt; &#039; + $(this).text() + &#039; &lt;/select&gt;&#039;);
        var keywords = {};
        $table.find(&#039;tbody tr td&#039;).filter(&#039;:nth-child(&#039; + (column + 1) + &#039;)&#039;).each(function() {
          keywords[$(this).text()] = $(this).text();
        })

        $(&#039;&lt;option class=&quot;filter&quot;&gt;All&lt;/option&gt;&#039;).click(function() {
          $table.find(&#039;tbody tr&#039;).removeClass(&#039;filtered&#039;).not(&#039;.collapsed&#039;).show();
          $(this).addClass(&#039;active&#039;).siblings().removeClass(&#039;active&#039;);
          $table.trigger(&#039;stripe&#039;);
        }).addClass(&#039;clickable active&#039;).appendTo($filters);
        $.each(keywords, function (index, keyword) {
          $(&#039;&lt;option class=&quot;filter&quot;&gt;&lt;/option&gt;&#039;).text(keyword).bind(&#039;click&#039;,
                              {&#039;keyword&#039;: keyword}, function(event) {
            $table.find(&#039;tbody tr&#039;).each(function() {
              if ($(&#039;td&#039;, this).filter(&#039;:nth-child(&#039; + (column + 1) + &#039;)&#039;).text() == event.data[&#039;keyword&#039;]) {
                $(this).removeClass(&#039;filtered&#039;).not(&#039;.collapsed&#039;).show();
              }
              else if ($(&#039;th&#039;,this).length == 0) {
                $(this).addClass(&#039;filtered&#039;).hide();
              }
            });
            $(this).addClass(&#039;active&#039;).siblings().removeClass(&#039;active&#039;);
            $table.trigger(&#039;stripe&#039;);
          }).addClass(&#039;clickable&#039;).appendTo($filters);
        });
        $filters.insertBefore($table);
      }
    });
  });
  	// This ensures that the first option of each select remains visible
  	$(&quot;select.filters&quot;).each(function() {
  		$(&quot;:first-child&quot;).attr({ selected: &quot;selected&quot; })
	});
});&lt;/code&gt;&lt;/pre&gt;

The above code will generate a &lt;select&gt; for each column marked as filterable.  But, as soon as another select gets clicked, the previous filtering will be &quot;forgotten&quot; by the script.  In other words, only the last clicked select is considered.

Now, I wish to push filtering a step further, i.e. combining multiple filters.  The user should be able to filter rows using one select and then refine his/her search using other ones.

Any advice will be appreciated.

Thanks,
Corrado Fiore</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>justed want to say &#8220;Thanks!&#8221; for such an invaluable book.  I&#8217;m one of the many developers to whom Jquery (and your book) opened the doors of rich client scripting.</p>
<p>That said, I have a little question about table filtering.  I was able to set up filtering for my table using some &lt;select&gt;, using the following code:</p>
<pre><code>$(document).ready(function() {
  $('table.filterable').each(function() {
    var $table = $(this);
    $table.find('th').each(function (column) {
      if ($(this).is('.filter-column')) {
        var $filters = $('&lt;select class="filters"&gt; ' + $(this).text() + ' &lt;/select&gt;');
        var keywords = {};
        $table.find('tbody tr td').filter(':nth-child(' + (column + 1) + ')').each(function() {
          keywords[$(this).text()] = $(this).text();
        })

        $('&lt;option class="filter"&gt;All&lt;/option&gt;').click(function() {
          $table.find('tbody tr').removeClass('filtered').not('.collapsed').show();
          $(this).addClass('active').siblings().removeClass('active');
          $table.trigger('stripe');
        }).addClass('clickable active').appendTo($filters);
        $.each(keywords, function (index, keyword) {
          $('&lt;option class="filter"&gt;&lt;/option&gt;').text(keyword).bind('click',
                              {'keyword': keyword}, function(event) {
            $table.find('tbody tr').each(function() {
              if ($('td', this).filter(':nth-child(' + (column + 1) + ')').text() == event.data['keyword']) {
                $(this).removeClass('filtered').not('.collapsed').show();
              }
              else if ($('th',this).length == 0) {
                $(this).addClass('filtered').hide();
              }
            });
            $(this).addClass('active').siblings().removeClass('active');
            $table.trigger('stripe');
          }).addClass('clickable').appendTo($filters);
        });
        $filters.insertBefore($table);
      }
    });
  });
  	// This ensures that the first option of each select remains visible
  	$("select.filters").each(function() {
  		$(":first-child").attr({ selected: "selected" })
	});
});</code></pre>
<p>The above code will generate a &lt;select&gt; for each column marked as filterable.  But, as soon as another select gets clicked, the previous filtering will be &#8220;forgotten&#8221; by the script.  In other words, only the last clicked select is considered.</p>
<p>Now, I wish to push filtering a step further, i.e. combining multiple filters.  The user should be able to filter rows using one select and then refine his/her search using other ones.</p>
<p>Any advice will be appreciated.</p>
<p>Thanks,<br />
Corrado Fiore</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teresa hurley</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-19547</link>
		<dc:creator>teresa hurley</dc:creator>
		<pubDate>Wed, 07 Nov 2007 20:13:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-19547</guid>
		<description>Hi Guys,

Thanks for a great book to help me learn jQuery! I&#039;ve been out of the js loop for a few years, doing more administrative type stuff at my job... but lately I&#039;ve been asked to get back into helping with actual coding. So I have a lot of catching up to do, and this is a great help.

I&#039;m working through the book, and happen to be on this chapter. I&#039;d like to submit a jQuery 1.2.1 problem and its fix as well as a Safari problem I just can&#039;t seem to get around.

First, the jQuery 1.2.1 problem/fix:

In the pagination code in tables.js, I was getting an error that &lt;code&gt;$table.find(&#039;tbody tr&#039;).show().lt()&lt;/code&gt; is not a function. After a bunch of searching, I found that  jQuery 1.2 doesn&#039;t support &lt;code&gt;.lt()&lt;/code&gt; or  &lt;code&gt;.gt()&lt;/code&gt; anymore. We now must use  &lt;code&gt;.slice(0, n)&lt;/code&gt; in place of  &lt;code&gt;.lt()&lt;/code&gt; and  &lt;code&gt;.slice(n+1)&lt;/code&gt; in place of  &lt;code&gt;.gt()&lt;/code&gt;, thus:
&lt;code&gt;$(document).ready(function()
{
	$(&#039;table.paginated&#039;).each(function()
	{
		var currentPage = 0;
		var numPerPage = 10;
		var $table = $(this);
		$table.bind(&#039;repaginate&#039;,
		 	function()
			{
		    	$table
					.find(&#039;tbody tr&#039;)
					.show()
					//lt was removed from jquery, use slice instead
			                    //.lt(currentPage * numPerPage)
					//new syntax:
					.slice(0, currentPage * numPerPage)
			          .hide()
			        .end()
					//gt was removed from jquery, use slice instead
			                    //.gt((currentPage + 1) * numPerPage - 1)
					//new syntax:
					.slice((currentPage + 1) * numPerPage - 1)
			          .hide()
			        .end();			
			});
//...code continues&lt;/code&gt;
Hopefully, that&#039;ll help anyone else new and struggling as I am.

Now for my Safari vs. collapsing table rows problem.

I&#039;m using Safari 2.0.4. It appears that &quot;opacity&quot; is not a property of &lt;tr&gt; (or thead, tbody, tfoot, for that matter). So the collapse code just makes the rows disappear, but not fade out prettily. Then, when I un-collapse, the spacing is all messed up: too much space between table rows, table row height shrinking, etc. Using hide/show instead of fadeOut/fadeIn works as expected (w/o the fade effect, obviously, but also with no funkiness w/regard to spacing).

The most recent thing I tried was to fade out the table cells instead of the rows. The first fade out appears to work fine. Fade in, however, does not: it seems to actually add table cells to each row (and they don&#039;t fade, in, they just appear). Then, subsequent fade outs are flaky: the rows are not completely absent. This also breaks firefox on the fade out, in that it leaves a space between the &lt;th&gt; row above and below the collapsed rows. Example here: http://hurleyhouse.com/learning_jquery/chapter_7/news/

I&#039;ve searched and searched, and haven&#039;t been able to find anyone else having the problem... Am I alone? Does anyone know of a workaround? Or is it possible I&#039;ve just done something completely wrong here?
&lt;code&gt;$(document).ready(function()
{
	var toggleMinus = &#039;../icons/bullet_toggle_minus.png&#039;;
	var togglePlus = &#039;../icons/bullet_toggle_plus.png&#039;;
	var $subHead = $(&#039;tbody th:first-child&#039;);
	$subHead.prepend(&#039;&lt;img src=&quot;&#039;+toggleMinus+&#039;&quot; alt=&quot;collapse this section&quot; /&gt;&#039;);
	$(&#039;img&#039;, $subHead)
		.addClass(&#039;clickable&#039;)
		.click(function()
		{
			var toggleSrc = $(this).attr(&#039;src&#039;);
			if (toggleSrc == toggleMinus)
			{
				$(this)
				.attr(&#039;src&#039;, togglePlus)
				.parents(&#039;tr&#039;)
				.siblings()
				.addClass(&#039;collapsed&#039;)
			//	.hide(); //works fine in safari
				
				.children() //need this for next to work in safari, because safari doesn&#039;t allow tr opacity
					      /*
                                              problem is, it leaves a big space in firefox (mac, anyway) also fadein is broken
						      see fadein note below
					      */
				.fadeOut(&#039;slow&#039;);
			}
			else
			{
				$(this)
				.attr(&#039;src&#039;, toggleMinus)
				.parents(&#039;tr&#039;)
				.siblings()
				.not(&#039;.filtered&#039;)
				.removeClass(&#039;collapsed&#039;)
			//	.show(); //works fine in safari, when hide is used above
				
				/*
                               the following totally breaks in safari... each time it&#039;s called, it adds more table cells
				    first, it&#039;s  one td for each existing td, then subsequent, it&#039;s one less than the original
				    number of tds... so you have four at first, then eight, then eleven, then fourteen, etc.
                          */
				.children()
				.fadeIn(&#039;slow&#039;);
			}
		});
});&lt;/code&gt;

thanks so much!
tree</description>
		<content:encoded><![CDATA[<p>Hi Guys,</p>
<p>Thanks for a great book to help me learn jQuery! I&#8217;ve been out of the js loop for a few years, doing more administrative type stuff at my job&#8230; but lately I&#8217;ve been asked to get back into helping with actual coding. So I have a lot of catching up to do, and this is a great help.</p>
<p>I&#8217;m working through the book, and happen to be on this chapter. I&#8217;d like to submit a jQuery 1.2.1 problem and its fix as well as a Safari problem I just can&#8217;t seem to get around.</p>
<p>First, the jQuery 1.2.1 problem/fix:</p>
<p>In the pagination code in tables.js, I was getting an error that <code>$table.find('tbody tr').show().lt()</code> is not a function. After a bunch of searching, I found that  jQuery 1.2 doesn&#8217;t support <code>.lt()</code> or  <code>.gt()</code> anymore. We now must use  <code>.slice(0, n)</code> in place of  <code>.lt()</code> and  <code>.slice(n+1)</code> in place of  <code>.gt()</code>, thus:<br />
<code>$(document).ready(function()<br />
{<br />
	$('table.paginated').each(function()<br />
	{<br />
		var currentPage = 0;<br />
		var numPerPage = 10;<br />
		var $table = $(this);<br />
		$table.bind('repaginate',<br />
		 	function()<br />
			{<br />
		    	$table<br />
					.find('tbody tr')<br />
					.show()<br />
					//lt was removed from jquery, use slice instead<br />
			                    //.lt(currentPage * numPerPage)<br />
					//new syntax:<br />
					.slice(0, currentPage * numPerPage)<br />
			          .hide()<br />
			        .end()<br />
					//gt was removed from jquery, use slice instead<br />
			                    //.gt((currentPage + 1) * numPerPage - 1)<br />
					//new syntax:<br />
					.slice((currentPage + 1) * numPerPage - 1)<br />
			          .hide()<br />
			        .end();<br />
			});<br />
//...code continues</code><br />
Hopefully, that&#8217;ll help anyone else new and struggling as I am.</p>
<p>Now for my Safari vs. collapsing table rows problem.</p>
<p>I&#8217;m using Safari 2.0.4. It appears that &#8220;opacity&#8221; is not a property of &lt;tr&gt; (or thead, tbody, tfoot, for that matter). So the collapse code just makes the rows disappear, but not fade out prettily. Then, when I un-collapse, the spacing is all messed up: too much space between table rows, table row height shrinking, etc. Using hide/show instead of fadeOut/fadeIn works as expected (w/o the fade effect, obviously, but also with no funkiness w/regard to spacing).</p>
<p>The most recent thing I tried was to fade out the table cells instead of the rows. The first fade out appears to work fine. Fade in, however, does not: it seems to actually add table cells to each row (and they don&#8217;t fade, in, they just appear). Then, subsequent fade outs are flaky: the rows are not completely absent. This also breaks firefox on the fade out, in that it leaves a space between the &lt;th&gt; row above and below the collapsed rows. Example here: <a href="http://hurleyhouse.com/learning_jquery/chapter_7/news/" rel="nofollow">http://hurleyhouse.com/learning_jquery/chapter_7/news/</a></p>
<p>I&#8217;ve searched and searched, and haven&#8217;t been able to find anyone else having the problem&#8230; Am I alone? Does anyone know of a workaround? Or is it possible I&#8217;ve just done something completely wrong here?<br />
<code>$(document).ready(function()<br />
{<br />
	var toggleMinus = '../icons/bullet_toggle_minus.png';<br />
	var togglePlus = '../icons/bullet_toggle_plus.png';<br />
	var $subHead = $('tbody th:first-child');<br />
	$subHead.prepend('&lt;img src="'+toggleMinus+'" alt="collapse this section" /&gt;');<br />
	$('img', $subHead)<br />
		.addClass('clickable')<br />
		.click(function()<br />
		{<br />
			var toggleSrc = $(this).attr('src');<br />
			if (toggleSrc == toggleMinus)<br />
			{<br />
				$(this)<br />
				.attr('src', togglePlus)<br />
				.parents('tr')<br />
				.siblings()<br />
				.addClass('collapsed')<br />
			//	.hide(); //works fine in safari</p>
<p>				.children() //need this for next to work in safari, because safari doesn't allow tr opacity<br />
					      /*<br />
                                              problem is, it leaves a big space in firefox (mac, anyway) also fadein is broken<br />
						      see fadein note below<br />
					      */<br />
				.fadeOut('slow');<br />
			}<br />
			else<br />
			{<br />
				$(this)<br />
				.attr('src', toggleMinus)<br />
				.parents('tr')<br />
				.siblings()<br />
				.not('.filtered')<br />
				.removeClass('collapsed')<br />
			//	.show(); //works fine in safari, when hide is used above</p>
<p>				/*<br />
                               the following totally breaks in safari... each time it's called, it adds more table cells<br />
				    first, it's  one td for each existing td, then subsequent, it's one less than the original<br />
				    number of tds... so you have four at first, then eight, then eleven, then fourteen, etc.<br />
                          */<br />
				.children()<br />
				.fadeIn('slow');<br />
			}<br />
		});<br />
});</code></p>
<p>thanks so much!<br />
tree</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-15892</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Thu, 11 Oct 2007 22:23:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-15892</guid>
		<description>Hi Joe, 

The &lt;code&gt;.is()&lt;/code&gt; method is not xpath. Is the period after &quot;is&quot; in your code above a typo? It shouldn&#039;t be there. We have a &lt;a href=&quot;http://book.learningjquery.com/bookstore/books/&quot; rel=&quot;nofollow&quot;&gt;working demo&lt;/a&gt; that you might want to look at for comparison.</description>
		<content:encoded><![CDATA[<p>Hi Joe, </p>
<p>The <code>.is()</code> method is not xpath. Is the period after &#8220;is&#8221; in your code above a typo? It shouldn&#8217;t be there. We have a <a href="http://book.learningjquery.com/bookstore/books/" rel="nofollow">working demo</a> that you might want to look at for comparison.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-15628</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Tue, 09 Oct 2007 22:18:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-15628</guid>
		<description>Interesting - so far I&#039;m doing well with the book, but got my first real stumper on the next line of the same script:

&lt;code&gt;
if ($(this).is.(&#039;.sortAlpha&#039;))	{
&lt;/code&gt;

where I get a &quot;XML filtering predicate operator called on incompatible Function&quot; error in Firebug.

is .is xpath?</description>
		<content:encoded><![CDATA[<p>Interesting &#8211; so far I&#8217;m doing well with the book, but got my first real stumper on the next line of the same script:</p>
<p><code><br />
if ($(this).is.('.sortAlpha'))	{<br />
</code></p>
<p>where I get a &#8220;XML filtering predicate operator called on incompatible Function&#8221; error in Firebug.</p>
<p>is .is xpath?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl</title>
		<link>http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation/comment-page-1#comment-14954</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Wed, 03 Oct 2007 22:57:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2007/08/book-excerpt-table-manipulation#comment-14954</guid>
		<description>Hi Scott,
It&#039;s possible that you haven&#039;t included enough code. Whenever we store a jQuery object as a variable, we precede the variable with &quot;$&quot;. It could be that you don&#039;t have the &lt;code&gt;$table&lt;/code&gt; variable defined anywhere. Without looking back at the code, I think we had something like &lt;code&gt;var $table = $(this);&lt;/code&gt;.

The only reason it might fail in 1.2.1 as opposed to an earlier version is if we used an XPath selector there, but that doesn&#039;t seem to be the case.

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Hi Scott,<br />
It&#8217;s possible that you haven&#8217;t included enough code. Whenever we store a jQuery object as a variable, we precede the variable with &#8220;$&#8221;. It could be that you don&#8217;t have the <code>$table</code> variable defined anywhere. Without looking back at the code, I think we had something like <code>var $table = $(this);</code>.</p>
<p>The only reason it might fail in 1.2.1 as opposed to an earlier version is if we used an XPath selector there, but that doesn&#8217;t seem to be the case.</p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced (User agent is rejected)
Database Caching 7/19 queries in 0.005 seconds using disk: basic
Object Caching 371/374 objects using disk: basic
Content Delivery Network via learningjquery.kswedberg.netdna-cdn.com

Served from: www.learningjquery.com @ 2012-02-08 17:20:24 -->
