Using the Taconite jQuery Plugin under Zope

The AJAX Framework jQuery is considered one of the easiest to use and most light libraries. Particularly the expandability via plugins has moved multiple developers to develop various Open Source expansion tools. This article deals with the jQuery Taconite plugin in conjunction with Zope.

Generate client-based effects with server technologies

The claim in the slogan of the jQuery developers "jQuery: The Write Less, Do More, JavaScript Library" is certainly not exaggerated. Rarely was it this easy to create cross-browser Javascripts and still retain a certain overview.

Nonetheless, the developers who are used to generating web applications logic using server technologies are having difficulties to cope with the syntactic challenges.

Example

In this article we want to show that it doesn't require so much as a single Javascript line in order to generate impressive effects on the client side. We want to prove this using an example: a click on the client side is supposed to request the sitemap of the website from the server. The result should then be embedded in a particular part of a document.

Prerequisites

One prereqiusite for this example is that the jQuery library and the Taconite plugin are embedded in the website (see Resources). The following HTML code should be placed in the <head> tag of the HTML page.

The Client Side

Clicking on the link triggers a XMLHTTPRequest to the URL /tutorials/taconite/sitemap. Here it is necessary to observe that merely this query needs to be triggered via the Javascript code. The rest is processed by the Taconite plugin. You can test this functionality by clicking on the hyperlink in the rendered view below.

The Server Side

The DMTL method sitemap generates a Taconite XML document. This document contains the commands and the source code for the sitemap to be embedded.

This code is intended to trigger the following:

  • the DIV element with the ID attribute "example2" is masked out
  • its content is replaced with the HTML code of the sitemap
  • the element is made visible again using a "slide effect"
  • the background color all P elements is switched to white
  • all H2 and H3 topics are colored red
  • last but not least, a Javascript dialog is opened

Conclusion

The Taconite plugin is a tool with which one can define very declarative client-based effects. The good readability of the Taconite commands brings a small amount of source code over head when compared to the even more compact jQuery syntax. Nonetheless, the benefits are obvious:

  • The Taconite syntax is easier to read, even for the layperson.
  • AJAX- effects on the client can be generated easily using common server technologies. Furthermore, it is irrelevant if the server is operating under a PHP, Zope, or an ASP.NET environment.
  • One AJAX query suffices to change a website at multiple parts, purveying new content.

Resources