The Third Degree
I’ve recently been building a basic shopping cart system using the Cake Framework. I’ve been relying heavily on Prototype and all the beautiful effects from script.aculo.us During this process (with the help from Travis) I’ve had a few epiphanies regarding the javascript landscape.
The last couple years have been occupied with a popular movement towards separation of presentation and structure with CSS/XHTML. I think most of us applaud this movement but now it’s time to push for a third degree of separation, Functionality. Since Prototype is effortless to implement we can begin to sprinkle it everywhere and before long our documents become difficult to read.
This has lead me to re-think how Structure, Presentation, and now Functionality coexist. My current method is getting everything functioning without javascript. This assures that if a person has javascript disabled the site will continue to function properly. I then go back using a single .js file and create appropriate classes around the needed functionality points and execute them using a window.onload event. The trick is meticulous naming of id’s in the XHTML.
I highly recommend this method for those of you getting your kicks with Ajax. Ajax is great but if you don’t have a backup plan your screwed and having this third degree ensures a graceful degrade.
Remarks
Nathan Borror http://www.playgroundblues.com/
Unfortunatly one of the biggest drawbacks of cake is its lack of documentation. That is suposidly changing with the release of 0.92 due any day.
In the mean time I use the following: http://groups-beta.google.com/group/cake-php http://www.cakephp.org/ http://sputnik.pl/cake/
Scott Becker
Whats even more awesome is Behaviour, which allows you to apply javascript behaviours ? event handlers to HTML elements using css selectors. The syntax is very simple, and you dont have to meticulously name all of your HTML elements, you simply use css selectors!
http://ripcord.co.nz/behaviour/
I recently used it on a project, and after finishing I looked at my HTML and it looked the same, no javascript soup. Totally seperate and clean.
Remarks are closed.
Remarks have been close for this post.