The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Code missing from 'Build your own AJAX Web Applications'?

I am currently reading "Build your own AJAX Web Applications" and believe I may have spotted some code which is missing, but not currently listed in the errata.

On page 136 the author states "As a temporary measure, we'll attach event handlers to the ondblclick events of these two entries in the init method of our Blog class" which is then followed by the JavaScript to do that. The problem is that this does not appear to be changed later on, meaning that this script is only ever capable of changing the first two entries. Is this something which should have been changed later, or have I merely missed the section where it is revised?

I've had a look through that chapter and I believe that it wasn't the authors intention to cover the loading of existing story content.

The use of "As a temporary measure" does suggest the author will deal with it later on in the chapter but it's not until the end, under 'Future Enhancements" that it is mentioned again. So, I can see how it's misleading.

If you run the demo from the code archive, which has no existing entries, you'll see that new entries become editable after they are saved. I believe the author's intention was to show a simple demo that implements creating, editing and saving via Ajax - which it does, if only in a limited fashion.

Incidentally if you do run the code from the archive on a web server, the Ajax form is submitted to a root-relative URI, which means you have to place the demo in the root folder of your web server. If you do not wish to do that you can change it so the whole demo runs within the same folder as the blog.html file.

Which means that the Elements with id values main1 and main2 are the only editable entries, because the ondblclick event is not set for any others. However, later, at the end of his excerpt on page 163 he writes:

Code:

entryDiv.ondblclick = self.toggleEditInPlace;

This code effectively adds the event handler action to the new entry which has been saved. This made me realise that these event handlers, as they are not specific to each entry, can presumably be put within the HTML - they do not need to be dynamically added by the javascript as on page 136:

Code:

<div id="main3" ondblclick="blog.toggleEditInPlace;">

Though this does not appear to have been indicated in the text. Am I right?