Build your own Ajaxs applications - Chapter 5


has anybody been able to put example of chapter 5 in practice?

The chapter starts with entering some sample entries to the page.

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:

so enter

var entry1 = document.getElementById(‘main1’);
var entry2 = document.getElementById(‘main2’);
entry1.ondblclick = self.toggleEditInPlace;
entry2.ondblclick = self.toggleEditInPlace;

and then it goes on saying:

We’ll replace this code later, but it will serve our current development purposes just fine.

And that’s all working fine, but as I read the chapter I did not find any replacement.

Lets say I like to use it on real web site where I would have 15+ comments. How can I attach the double click event to all of them? In the book
we hard wire 2 comments but that about it.

Obviously the code should be finding all available comments and making them editable on the double click event.

Did I miss something? Please if you have some experience, let me know.


I need to read the chapter itself so my answer may not be very accurate… but if you are thinking about generalising the concept, you’ll need a function that sets a generic var entry with the correct elment ID and then toggle the Edition.

Now, I don’t remember the code so I’d probably need to read the chapter again. More into JQuery these days :lol:

Thanks for your reply!

I have a project where I need to implement a solid solution for edit in place functionality.

Do you know about any good solutions?


There are plenty of examples out there with and without JQuery. Are you creating the page, or are you using something like Joomla or WordPress or any other CMS?

I am not using any CMS, just building stand alone application.