AJAX/Modal Functionality: 0 Lines of Javascript, 200% More Chaos Magic

9

December 9, 2009 - 7:52am

Tags :

While attending DrupalCampNYC7 this past weekend at NYU Poly, one of the most eye-popping demos I saw was by Roger López, showing off some functionality hiding in the Chaos Tools Suite to empower you to create awesome AJAX functionality, including modal dialogs/forms, without writing a single line of javascript. You can read Roger's presentation notes here, which I strongly recommend.

Needless to say, I was immediately jazzed by the possibilities of a clean programmatic mechanism for handling data exchanges of this nature. It's complex work, and doing it on a one-off basis is tricky and prone to error. This is why we're all so lucky to be in the same coding community as Merlinofchaos: not only do we get killer apps like Views, we get the infrastructure he writes "for himself" that goes along with it!

I was also sort of surprised/chagrined that I'd been working on Panels all year long and never known about this wondrous gem of an API. But that's a problem I know how to solve: I thought, "hey, this should be a sample module included with ctools by default."

So, on the plane from LaGuardia to New Orleans (where I'm presenting on Friday at Do It With Drupal), I took my own stab at it. This isn't a lot more code than Roger presented, but I cleaned up the namespace and used a few more of the ctools functions.

The sample module shows how to perform simple operations like text replacements, table manipulation, and a modal login form. I'd love to hear other use-cases that would be worthwhile to include in a sample module (chime in on the issue thread). I'm also looking forward to digging in further to add new ctools_ajax/modal commands, so if you've got any great ideas let me know.

It's a great time to be a Chaos Wizard!

Comments

Josh, thanks for the kind words. I must say that CTools has really opened my eyes to a better developer experience and I'm glad to see some of it seeping into drupal 7.

If you're interested, the dialog demo I showed at camp is up at http://drupal.org/project/dialog.

Thanks Roger and Josh.

I will take a deeper look but I've tried both demo's and looks nice. I tried with JS disabled and Josh's module doesn't degrade gracefully, at least in Firefox.

Intimately, the publish is truly the top on this valuable subject. I concur with your conclusions and will eagerly look forward for your coming updates!….

I am not really sure where to integrate it. Please offer me more details.

ballbusting

you have above Roger's presentation. If you will follow those steps then you will have excellent results for sure.

rap beats

I follow your advices, but I have some warnings... why?

route 53

I will do it... hope to have good results.

seems to be an organized chaos... I like your approach. It is really interesting! Coppell Pediatrician

for me is more a chaos than something magic. I will try to adapt it, but I am not sure about the results.

Post a comment

To prevent automated spam submissions leave this field empty.
CAPTCHA
Let us know you're human by typing in this code. The code is case sensitive.
Image CAPTCHA
Enter the characters shown in the image.