Errata

JavaScript Web Applications

Errata for JavaScript Web Applications

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Other Digital Version
1
Near end

"Now lets create an attributes() function, which will return an object of attributes to values"

This sentence could be rewored, also thinking calling the list of attributes on the model the same thing as the method on the instance could lead to confusion.

Page number not correct in my report.

Anonymous  Oct 06, 2011  Jul 18, 2014
5
Comment on the source code in "The Controller"

In your book say "// Use a anonymous function to enscapulate scope". I think "encapsulate" is correct word.

Kotaro yoshida  Aug 30, 2011  Jul 18, 2014
PDF
Page 9
code example after the second paragraph

In that line of code:

destroy: functions(id) { /* ... */ }

should be "function", not "functions"

Dmitriy Koroliov  Jul 03, 2012  Jul 18, 2014
PDF
Page 13
Polska

var App {

should be

var App = {

Krzysztof Kula  Nov 14, 2011  Jul 18, 2014
Printed
Page 13
middle of page


$('.clicky').click(proxy(this.wasClicked, this));
should be:

$('.clicky').click(proxy(self.wasClicked, this));

Anonymous  Dec 21, 2012  Jul 18, 2014
Printed
Page 16
1st code example

"integer" is not a valid type in JavaScript. See: http://es5.github.com/#x11.4.3

Rick Waldron  Oct 14, 2011  Jul 18, 2014
PDF
Page 17
Second code block

in the Student class, it seems that "price" should be "pay".

emanchado  Sep 21, 2011  Jul 18, 2014
Printed
Page 22
2nd paragraph

The example should be using the target property, not the currentTarget, because the li is the target of the bubbling event.
Using currentTarget, the condition won't ever be met.

// Delegating events on a ul list
list.addEventListener("click", function(e){
if( e.target.tagName == "li" )
{
return false;
}
});

Eric Priou  Jan 15, 2012  Jul 18, 2014
PDF
Page 23
Next-to-last code sample

jQuery.ready(function($){

should be

jQuery(document).ready(function($){

The code 'jQuery.ready(function)' doesn't queue up a function callback for when the DOM is ready, as stated, but actually delivers to jQuery notification that the DOM is ready. To queue up a DOMContentLoaded callback, you call the .ready function on a jQuery element instance, not the 'static' .ready function on the jQuery object itself.

Royston Shufflebotham  Oct 26, 2011  Jul 18, 2014
PDF
Page 24
1st sample of code under headline "Delegating Events"

rather than
if(e.currentTarget.tagName == "li"

it should be
if(e.target.tagName == "LI")

All three major browser (FF,IE9, Chrome) returns tagName in capital latters.

Muhammad Atif  Oct 14, 2012  Jul 18, 2014
Printed
Page 26
Last code example

The semi colon at the end of: var element = $(this); will cause the var on the next line to be leaked globally

Rick Waldron  Oct 14, 2011  Jul 18, 2014
PDF
Page 29
Entire Page from "If you?re using jQuery"

"It?s so simple, in fact, that we can put it inline:"

I think maybe here the word simple should be replaced with "short". I was also surprised more explanation wasn't provided with this code.

I also tried this with code as-is with the latest version of JQuery and only the first argument made it to the subscriber.

Anonymous  Oct 04, 2011  Jul 18, 2014
PDF
Page 29
code

$.publish("/some/topic", "a", "b", "c");

s/b

$.publish("/some/topic", ["a", "b", "c"]);

Tsuyoshi Toyofuku  Oct 06, 2011  Jul 18, 2014
PDF
Page 36
Mide way.

Possibly a mistake:

"return this.records[id] || throw("Unknown record");"

Anonymous  Oct 05, 2011  Jul 18, 2014
Printed
Page 37
Near top of page, Model.extend() { ...

On page 35 we attached the function "create" to the Model object using the "Model.include" function. On page 37 we changed "create" to include automatic id generation but then use "Model.extend". Probably just meant "Model.include"? "Model.extend" overwrites the "Model.create" function which was previously used to mint new instances of the Model object.

Anonymous  Oct 05, 2011  Jul 18, 2014
PDF
Page 37
Near end

"Asset.extend({
find: function(id){"

I think you maybe mean Model not Asset here (but I could be wrong).

Anonymous  Oct 05, 2011  Jul 18, 2014
PDF
Page 37
Bottom of page

When creating the asset instance, the book uses the new keyword:
var asset = new Asset( { name: "foo" });

This should instead be:
var asset = Asset.init( { name: "foo"} );

Anonymous  Feb 04, 2013  Jul 18, 2014
Printed
Page 47
middle of page

I believe "var" in:

var Model.LocalStorage = {....

be omitted to read like:

Model.LocalStorage = {....

Anonymous  Jun 19, 2013  Jul 18, 2014
PDF
Page 52
Quote given

"mod.fn.load = function(func){
$(this.proxy(func));
};"

Two things strike me here, one is that the name "mod" isn't that helpful and secondly that somewhere in the text or with a comment you might want to point out the way this is working (e.g. running function when documents ready). It'd just make the section a little bit easier to follow.

Colin Jack  Oct 07, 2011  Jul 18, 2014
PDF
Page 53
Code block, top

Both jQuery's mouseover and mouseout methods accept a single callback function. Here they are also given a second boolean argument.

Tim Fletcher  Jan 08, 2012  Jul 18, 2014
PDF
Page 54
Second code block on the page

?? this.toggleClass: function(e){ ?? should be ?toggleClass: function(e){?

Anonymous  Jan 04, 2013  Jul 18, 2014
PDF
Page 62
First line of code

jQuery(function(){
shall be
jQuery(function($){
as the "$" variable is used in line 4, as
$(window).trigger("hashchange");

Behnam Esfahbod  Dec 30, 2011  Jul 18, 2014
PDF
Page 72
Top

"var calls = this._callbacks || (this._callbacks = {});"
"if (!(calls = this._callbacks)) return this;"

Nothing is done with calls afterwards. Not a big issue I admit, but it would help improve the code a bit (same maybe for not using names like calls/list but I guess thats arguable).

Colin Jack  Oct 18, 2011  Jul 18, 2014
PDF
Page 73
3rd paragraph

?First you have to transfer any data needed for the view to the client, as don't [you don't? the library doesn't] have access to server side variables."

bhanafee  Jun 01, 2011  Aug 11, 2011
PDF
Page 74
1st paragraph

?The reason being is that??

bhanafee  Jun 01, 2011  Aug 11, 2011
Printed
Page 75
2nd code example, last line

Parentheses don't match. There's an extra closing bracket in the last line.
}), ["./maths"]);
->
}, ["./maths"]);

Antti Ahti  Nov 22, 2011  Jul 18, 2014
PDF
Page 75
2nd paragraph

a HTML fragment...an JavaScript object
s/b
an HTML fragment...a JavaScript object

bhanafee  Jun 01, 2011  Aug 11, 2011
PDF
Page 75
4th paragraph

"It renders a rendered template element"

Redundant and says the same thing twice.

Note from the Author or Editor:
Fixed - thanks so much!

bhanafee  Jun 01, 2011  Aug 11, 2011
PDF
Page 75
2nd from bottom paragraph

Whatever is inside the brackets get executed in the context of the object passed to jQuery.tmpl(), regardless if it's a property or function.

executed s/b evaluated. If it's a property, it can't be executed.

"get" s/b "gets" or "is"

"regardless if" could be reworded too.

Note from the Author or Editor:
Fixed - thanks so much!

bhanafee  Jun 01, 2011  Aug 11, 2011
PDF
Page 76
India

Under the Yabble section:

< script >
require.setModuleRoot("javascripts");
// We can use script tags if the modules
// are wrapped in the transport format

require.useScriptTags();
require.ensure(["application"], function(require) { // Application is loaded
});
< /script>

then in next paragraph:
The above example will fetch our wrapped application module and then load its dependencies, utils.js, before running the module.

While util.js is not specified as dependency in above code.

Mahesh  May 25, 2013  Jul 18, 2014
Printed
Page 109
United States

The first code sample on page 109 reads "var asset" when it should be "var assert".

Simon  Oct 14, 2011  Jul 18, 2014
Printed
Page 111
United States

Deprecated/Renamed QUnit functions:

equals() changed to equal()
same() changed deepEqual()

Rick Waldron  Oct 14, 2011  Jul 18, 2014
Printed
Page 116
3rd paragraph

"Crome" instead of "Chrome"

Oliver Schmidt  Sep 21, 2011  Jul 18, 2014
PDF
Page 119
1st code sample

'asset' should be 'assert'

"For example, here's the simple assert() function we've been using for the examples throughout this book.
"var asset = function(value, msg) {...}"

Michael Edmondson  Jul 12, 2011  Jul 18, 2014
PDF
Page 136
First code block on the page

shouldn't the Content-Type be image/gif?

emanchado  Sep 21, 2011  Jul 18, 2014
PDF
Page 137
Middle of the page

The YUI compressor command-line should redirect (">"), not pipe ("|")

emanchado  Sep 21, 2011  Jul 18, 2014
PDF
Page 139
Last line of the page

both "Google" and "Yahoo!" links point to the same URL.

emanchado  Sep 21, 2011  Jul 18, 2014
PDF
Page 141
4th paragraph

"support; Spine.Class" should be "support, Spine.Class".

emanchado  Sep 21, 2011  Jul 18, 2014
PDF
Page 144
Near end

Properties in subclasses can be overridden without affecting the parent class. However,
modifications to objects in subclasses, such as arrays, will be reflected across the whole
inheritance tree. If you want an object to be specific to a class or instance, you?ll need
to create it when the class or instance is first initialized. You can do this in a created
() function, which Spine will call when the class is first set up or instantiated:

// We want the records array to be specific to the class
var User = Spine.Class.create({
// Called on instantiation
init: function(){
this.attributes = {};
}
}, {
// Called when the class is created
created: function(){
this.records = [];
}
});


Didn't fully understand the text so I moved to the code, however its pretty confusing too. Might be worth pointing out the created function needs to be passed in as a class property.

I also couldn't get the code to work when I typed it in so I copied it from the PDF and again no luck. Seems "created" isn't supported in the latest version of spine.

Colin Jack  Oct 23, 2011  Jul 18, 2014
PDF
Page 166
Second code block

shouldn't this:
assertEqual( User.instanceProperty, "foo" );
assertEqual( User.prototype.classProperty, "bar" );
be like this?
assertEqual( User.prototype.instanceProperty, "foo" );
assertEqual( User.classProperty, "bar" );

emanchado  Sep 21, 2011  Jul 18, 2014
PDF
Page 172
First code block in the "Controllers" section

the routes example is missing a comma after the
"search/:query/p:page" line.

emanchado  Sep 21, 2011  Jul 18, 2014
PDF
Page 172
5th paragraph beginning with "Routes are parsed"

"end" should be "beginning".

Anonymous  Mar 09, 2012  Jul 18, 2014
PDF
Page 177
3rd paragraph

"Underscore providers" s/b "Underscore provides".

bhanafee  Jun 01, 2011  Aug 11, 2011
PDF
Page 184
Titel and subsequent mentions

Controllers are now called Routers in Backbone.js

Joachim Nolten  Jul 19, 2011  Aug 11, 2011
PDF
Page 193
2nd code sample

this.delegate('.next','click', function(){
paginate.attr('offset', paginate.offset+paginate.limit);
})
this.delegate('.prev','click', function(){
paginate.attr('offset', paginate.offset-paginate.limit);
});

should be

this.delegate('.next','click', function(){
paginate.next();
})
this.delegate('.prev','click', function(){
paginate.prev();
});

to use the helper methods created above.

Anonymous  Dec 15, 2011  Jul 18, 2014
PDF
Page 196
last code sample

var el = $('<li>').html(todo.name);

should be

var el = $('<li>').html(task.name);

Anonymous  Dec 15, 2011  Jul 18, 2014
PDF
Page 198
5th paragraph

"This is due to the fact that currently pushState() and replaceState() need special handling on the server side, and aren'tf yet supported by Internet Explorer."

aren'tf => aren't

mnmly  Jul 05, 2011  Aug 11, 2011
PDF
Page 208
Middle

"// Select the children of 'bar' with a class of 'foo'
var foo = $(".bar .foo");"

Colin Jack  Oct 24, 2011  Jul 18, 2014
PDF
Page 210
Example at the top of the page

The example is written:

var element = $("p");
element.addClass('bar");
element.text("Some content");

The first line should read

var element = $("<p>");

This error is present on page 210 of the PDF, position 425.3 of the ePub (per Calibre), position 5214 of the mobi (per Kindle DX), and position 380 of the mobi (per Calibre).

Troy Farrell  Dec 31, 2011  Jul 18, 2014
PDF
Page 212
Last example

The URL in the last example on page 212 of the PDF is given as:

http://example.com/endpoint.jso

It should probably be

http://example.com/endpoint.json

to be consistent with the other examples.

The error is present in the PDF, the ePub and the mobi files.

Troy Farrell  Dec 31, 2011  Jul 18, 2014
PDF
Page 225
Middle of the page

Opera appears twice.

Anonymous  Feb 14, 2012  Jul 18, 2014