Go To Homepage



Book Details
Practical Prototype and script.aculo.us book cover
  • By Andrew Dupont
  • ISBN13: 978-1-59059-919-8
  • ISBN10: 1-59059-919-5
  • 352 pp.
  • Published Jun 2008
  • Print Book Price: $39.99
  • eBook Price: $27.99



Errata Submission

If you think that you've found an error in Practical Prototype and script.aculo.us, please let us know about it. You will find any confirmed erratum below, so you can check if your concern has already been addressed.

Submit Errata
Practical Prototype and script.aculo.us (978-1-59059-919-8)

Errata

Issue Author's Response
Chapter 4, scores.php causes problems in Firefox 2 & 3. This is with PHP 5 installed. The problem has to do with

header("Content-type: application/json");

When this code is in, the browser alerts me and wants to treat scores.php as a file download. If I call

var request = new Ajax.Request("scores.php");

from index.php, I get no Response. If I call

var request = new Ajax.Request("scores.php", {
onSuccess: function(request) {
console.log(request.responseJSON);
}
});

I get null rather than Objects.

It's hard for me to believe I'm the first person to have this problem. By the way, I copied the source code provided and tried that, in case I had typed something wrong, but I get the same problems.

The bummer is, so much is based on this code, so where does that leave me for the rest of the book?
Works for me. What's your server software? It's possible certain versions of Apache need some mod_mime configuration (http://httpd.apache.org/docs/2.0/mod/mod_mime.html), but mine worked out of the box. Feel free to shoot me an e-mail at <book@andrewdupont.net> if you need more help.

Cheers,
Andrew
Chapter 3, page 32

The second code example:

var paragraphs = $$('p');
for (var i = 0; i < elements.length; i++)
makeTextRed(elements[i]);

shouldn't it be:

var paragraphs = $$('p');
for (var i = 0; i < paragraphs.length; i++)
makeTextRed(paragraphs[i]);
Yep. Thanks!
Hi,

the code in the book,

starting at page 249 (Bells and Whistles)

until page 254 does not work.

Is there an errata pdf document for this part available?

Thanks,

Udo

P.S.: So far a great book.
Can you be more specific? This is the first erratum I've received for this section.
Hi, the book is amazing, however I spotted something

On Chapter 4 - page 68 : the PHP script checks the presence of food_type and taste.

However once the form is added (chapter 5 : page 95) the php doesn't validate anymore, since isset() does not check for zero-length strings.

I have fixed it with this dirty code

//code
if (!isset ($_REQUEST['food_type']) || !isset ($_REQUEST['taste']) || $_REQUEST['food_type'] =="" || $_REQUEST['taste'] =="")

thanks for the excellent book
g
Correct. Thanks!
First problem; you don't list errata submitted by others on this site.

Chapter 11, p259

Code is written as $$('container li').each(function(li){ new Draggable(li);});

and it's different then the code in figure 11-1

AND it's different then the code that actually works:

$('container').select('li').each( function(li){ new Draggable(li); });
Correct. Thanks!
Love the book. If this is helpful, I'll send more as I get through the remaining chapters.

Practical Prototype and script.aculo.us

Chapter 1
Page 5
"new String instanceof Object; //-> true"

While this is true, I believe the author intended this to be:
new String('foo') instanceof Object; //-> true

Page 6
"... Prototype includes a more conventional system of OOP that allows ..."

I believe the author intended this to be:
... Javascript includes a more conventional system of OOP that allows ...

Page 8
"... Notice also how the second example ends with a semicolon after the
closing brace, since the braces aren’t a control structure ..."

I belive putting a semicolon after a function literal in this context is standard 'good style'; however, it is optional. One disadvantage of encouraging semicolons after function literals is in the case of a function literal inside an object literal where they are illegal as in this example:
var myObject = {
name: 'Sam',
cc: function (foo){
return foo + 'bar';
}, // semicolon after } is illegal
age: 35
}; // semicolon is optional here


Chapter 2
Page 21
"var firstDiv = document.getElementsByTagName('ul')[0];"
should be: var firstUl = document.getElementsByTagName('ul')[0];

"var firstUL = $$('div')[0];"
should be: var firstUL = $$('ul')[0];

Page 23
"Since objects are passed by reference, not value, the source object is modified..."
should be: Since objects are passed by reference, not value, the destination object is modified...

Page 25
"items = paragraphs.slice(1);"
should be: items = items.slice(1);

Page 26
"background-color: red;"
I would suggest "background-color: blue;" because the links are already red therefore, the first link won't show up as red text against a red background.

Page 28
"• $('input[type="text"]') will select all text boxes."
should be: • $$('input[type="text"]') will select all text boxes.

"• $$('ul#menu > li') li') selector> will select all li elements that are direct..."
should be: • $$('ul#menu > li') will select all li elements that are direct...
Love the book. If this is helpful, I'll send more as I get through the remaining chapters.

Practical Prototype and script.aculo.us

> Chapter 1
> Page 5
> "new String instanceof Object; //-> true"
>
> While this is true, I believe the author intended this to be:
> new String('foo') instanceof Object; //-> true

It doesn't matter in this case. You can leave off the parentheses when you're instantiating.


> Page 6
> "... Prototype includes a more conventional system of OOP that allows ..."
>
> I believe the author intended this to be:
> ... Javascript includes a more conventional system of OOP that allows ...

No, I'm saying that the class-based OOP that Prototype provides is probably more "conventional" to the reader than prototype-based OOP in JavaScript.


> Page 8
> "... Notice also how the second example ends with a semicolon after the
> closing brace, since the braces aren't a control structure ..."
>
> I belive putting a semicolon after a function literal in this context is standard 'good style'; however, it is optional. One disadvantage of encouraging semicolons after function literals is in the case of a function literal inside an object literal where they are illegal as in this example:
> var myObject = {
> name: 'Sam',
> cc: function (foo){
> return foo + 'bar';
> }, // semicolon after } is illegal
> age: 35
> }; // semicolon is optional here

Right, but the semicolon would still be illegal after a number literal or string literal in that context. The passing point I make there is that the braces are part of the function literal and bear more resemblance to other literals than they do to the braces of a function definition.


> Chapter 2
> Page 21
> "var firstDiv = document.getElementsByTagName('ul')[0];"
> should be: var firstUl = document.getElementsByTagName('ul')[0];
>
> "var firstUL = $$('div')[0];"
> should be: var firstUL = $$('ul')[0];
>
> Page 23
> "Since objects are passed by reference, not value, the source object is modified..."
> should be: Since objects are passed by reference, not value, the destination object is modified...
>
> Page 25
> "items = paragraphs.slice(1);"
> should be: items = items.slice(1);

You're correct about all of these.

> Page 26
> "background-color: red;"
> I would suggest "background-color: blue;" because the links are already red therefore, the first link won't show up as red text against a red background.

Sure, I suppose. :)

> Page 28
> "� $('input[type="text"]') will select all text boxes."
> should be: � $$('input[type="text"]') will select all text boxes.
>
> "� $$('ul#menu > li') li') selector> will select all li elements that are direct..."
> should be: � $$('ul#menu > li') will select all li elements that are direct...

Correct.

Thanks for the notes!

Cheers,
Andrew
Chapter 2, page 21:

In the first of the three bullets there is a variable named "firstDiv". I think this should be named "firstUL" in order to be correct (as well as consistent with the rest of the page).

In the second of the three bullets the line "var firstUL = $$('div')[0];" I think there are two mistakes: 'ul' should have been used rather than 'div'; $ should have been used instead of $$

Chapter 2, page 22-23: I'm not sure if it is a mistake or I simply don't grasp the point, but I don't see how the suggestion on page 23 is in any way shorter, superior, or less "carpal tunnel inducing" than the approach shown on page 22.
You're right about all the variable names.

Also, I picked poor examples to show how object literals can cut down on typing. Imagine a longer variable name than "data"; or else imagine assigning properties to "foo.bar.baz" or something else with a long property chain.

Thanks!
Chapter: 13
Page: 302

Description: the bold line in the code block at the bottom of the page should be:
Widget.Foo.instances[element.id] = this;
Yep. Thanks!