Learning jQuery 1.3

Errata

Code Download

/bookstore/scripts/tables.js, line 621

The code download from Packt Publishing's web site is missing a call to .trigger('repaginate') on line 621 of /bookstore/scripts/tables.js. It reads:

});

It should read:

}).trigger('repaginate');

Chapter 1

no errata yet

Chapter 2

pages 23-24

This CSS is missing from the Styling List-Item Levels example:

.sub-level {
  background: #ccc;
}

page 29

The snippet of CSS in the first paragraph reads:

.highlight {font-weight:bold; font-style: italics;}

It should read:

.highlight {font-weight:bold; font-style: italic;}

Chapter 3

page 40

The second code block reads:

' body').addClass('large');

It should read:

$('body').addClass('large');

Chapter 4

page 69

In the second code block we mistakenly use a second argument with the parseFloat function. While a second argument for parseInt "allows us to ensure that the number is interpreted as base-10," there is no such second argument for parseFloat. instead of octal or some other representation."

page 76

The last line in the last paragraph reads: we're changing the its text

It should read: we're changing its text

Chapter 5

no errata yet

Chapter 6

page 121

In the JSON example there is a ] missing at the end of the code example to close the JSON array.

Chapter 7

pages 200-202

In Chapter 7 when we discuss Interacting with Other Code, we recommend using the :visible pseudo-class to combine the filtering, striping, and collapsing scripts. As of jQuery 1.3.2, however, element visibility is detected differently, which renders our code ineffective. Therefore, the following line, which appears on both page 200 and page 202 should be changed:

$(this).find('tr:visible:not(:has(th))')

Instead of the :visible pseudo-class, we can use a filter function to test for the display style property:

$(this).find('tr:not(:has(th))')
  .filter(function() {
    return this.style.display != 'none';
  })
  // code continues

pages 200-202

A problem arises with some hidden rows not becoming visible again after the following sequence:

  1. Collapse a table section
  2. Filter the table by a category
  3. Expand the collapsed table section
  4. Click the "All" categories link

To avoid this issue, we need to add a line of code after the following:

$table.find('tbody tr').removeClass('filtered');

The previous code, along with the necessary addition, should look like this:

$table.find('tbody tr').removeClass('filtered');
// show rows that were previously hidden both by the filtered class and by a collapsed (but later expanded) section
$table.find('tbody:not(.collapsed)').find('tr').show();

Chapter 8

no errata yet

Chapter 9

no errata yet

Chapter 10

no errata yet

Chapter 11

no errata yet