Smashing jQuery Errata

During publishing of my book, Smashing jQuery it seems as though some errors have been introduced. The following is a list of the errors which I have spotted, if you find other errors, please fill out this form and I will make sure they get added to this list.

Page 32

The following code is incorrect:

  <script type="text/javascript"></>

It should be changed to:

  <script type="text/javascript">

Page 33

The code block below shows up twice on the bottom of the page, it should only be there once.

$(window).load {
  //jQuery Code Goes Here
  alert("This window has been loaded.");
});

$(window).load {
  //jQuery Code Goes Here
  alert("This window has been loaded.");
});

Page 40

The following code is incorrect:

  $(selector).method().

It should be changed to:

  $(selector).method();

Page 51

The following code is incorrect:

$('.book-one, .book-two, .book-three, .book-four, .book-five, #header, #footer p').css('background'’’,'#ccc'’’);

It should be changed to:

$('.book-one, .book-two, .book-three, .book-four, .book-five, #header, #footer p').css('background','#ccc');

Page 57

The following code is incorrect:

$('.content:has(p)').css('font-size'’’,'18px'’’);

It should be changed to:

$('.content:has(p)').css('font-size','18px');

Page 58

The following code is incorrect:

    $('.error:empty)').css('display','none');

It should be changed to:

    $('.error:empty').css('display','none');

Page 76

The code block below shows up twice on the bottom of the page, it should only be there once.

$(window).bind('unload', function() {
  alert('You have not finished filling out the form. Are you sure you want to leave?');
}

Page 77

The code block below shows up twice on the bottom of the page, it should only be there once.

$(window).unload(function() {
  alert('You have not finished filling out the form. Are you sure you want to leave?');
}

Page 78, 79

The code block below is missing single or double quotes around the click event handler.
The following code is incorrect:

$(document).ready(function() {
	$('.mylink').bind(click, alertMe)  
}

It should be changed to:

$(document).ready(function() {
	$('.mylink').bind('click', alertMe)  
}

Page 123

On step 7:

var slideText 

should be:

var slideNum 

On step 9:

var slideText 

should be:

var slideNum 

On step 9:
Anywhere slideText is referenced it should be replaced with slideNum

Page 126

On step 18:

$('#nav li a').bind('click', function(){
  $('#nav li a').removeClass('active');
  $(this).addClass('active');
  
  $(".slide-text").css({
  'top':'-100px',
  'right':'0px',
  });
  
  $(".slide-text").stop();
  $(".slide-text").clearQueue();

  var active = $('#nav li a.active').attr("rel") - 1;
  var slidePos = active * slideWidth; 
  var slideNum = $('#nav li a.active').attr("rel");

  $(".slides-container").animate({
  left: -slidePos,
  },1000, function(){
    $('.slide-text').addClass('textStrip'});
});

should be:

$('#nav li a').bind('click', function(){
  $('#nav li a').removeClass('active');
  $(this).addClass('active');
  
  $(".slide-text").css({
  'top':'-100px',
  'right':'0px',
  });
  
  $(".slide-text").stop();
  $(".slide-text").clearQueue();

  var active = $('#nav li a.active').attr("rel") - 1;
  var slidePos = active * slideWidth; 
  var slideNum = $('#nav li a.active').attr("rel");

  $(".slides-container").animate({
  left: -slidePos,
  },1000, function(){
    $('.slide-text').addClass('textStrip'});
  });
});

Page 189

On step 5:

$('#status').bind({
  keypress : function() {
    var inputText = $(this).val();
    var numChar = inputText.length;
    var charRemain = numChar - maxNum;
    if (numChar <= maxNum) {
        $('.counter').text(charRemain);
    }
  });
});

should be:

$('#status').bind({
  keypress : function() {
    var inputText = $(this).val();
    var numChar = inputText.length;
    var charRemain = numChar - maxNum;
    if (numChar <= maxNum) {
        $('.counter').text(charRemain);
    }
  }
});

Page 189

On step 7:

$('#status').bind({
  keypress : function() {
    var inputText = $(this).val();
    var numChar = inputText.length;
    var charRemain = numChar - maxNum;
    if (numChar <= maxNum) {
        $('.counter').text(charRemain);
    }
    else if (numChar > maxNum){
      event.preventDefault();
    }
  });
});

should be:

$('#status').bind({
  keypress : function() {
    var inputText = $(this).val();
    var numChar = inputText.length;
    var charRemain = numChar - maxNum;
    if (numChar <= maxNum) {
        $('.counter').text(charRemain);
    }
    else if (numChar > maxNum){
      event.preventDefault();
    }
  }
});

Page 268

On step 3:

<label>Date</label>
<input type="text" id="date" />
</div>  

should be:

<label>Date</label>
<input type="text" id="date" />

Comments

Bill S.
Reply

What about “Smashing jQuery,” p. 240… URL for the variable var query = “http://feeds.delicious.com/v2/json/jakerutter?count=10″ evidently has aged out ;-(
I’d really like to see this work; will search for other jsonp sites in the meantime.

Leave a Reply