I just want to go places in my car

I’ve rewritten the syndication Javascript using the Prototype library, which I can heartily recommend to anyone. After including it in your page using a <script> tag, you can activate an AJAX content updater (like the syndication system on the left here) with the following code:

// When the link is clicked, this does the updating function onClickingTheATag() { // Access the link that's clicked using "this" var MyAjax = new Ajax.Updater( elementThatWillContainTheContentID, urlToGetContentFrom, { method: 'get', parameters = 'a=b&clickid=' + this.id} ); } // Tell the browser to look for clicking on the link, // and run onClickingTheATag when that's done Event.observe( anchorTagID, "click", onClickingTheATag, false ); 

About as simple as you can get: one function call to determine what to do when a link is clicked, and one to tell the browser to watch out for link clicking. Prototype is a lot more than that, and comes with shorthands like $(elementID) to return the element of that ID, and $F(formElementName) to return the form element of that name. It’s hopelessly documented, but fortunately third party overviews and exhaustive unofficial documentation exist.

Also, Prototype is a gateway library to Script.aculo.us, the demos of which have to be seen to be believed that they’re not Flash. Have a play: finally, Javascript programming reaps more rewards than headaches.

Advertisements
This entry was posted in meta, technical. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s