the singularity of being and nothingness
Archive for May, 2009
Falling in Love with Aptana
May 17th
Yeah, so I'm really dumb. For a long time, I've used DreamWeaver pretty much exclusively as an IDE for my web projects. There's something that makes sense here, as it has pretty good HTML and CSS features, and some limited ColdFusion and XML niceties. However, it is the suck when it comes to JavaScript editing.
Today I discovered Aptana. Of course, I've used Aptana before…by used, I mean, of course, that I downloaded the free version and played around with it (especially the built in AIR support). However, I had never really used it to modify JavaScript.
Well, there is a new love in my life! Aptana is smart enough to take my JavaScript, spaghetti-code as it is, and self-document all of the functions and variables that I have set. They may not seem like a big deal, but when you have several hundreds of lines of JS code with inline comments, it can be a big pain to scroll around trying to find this or that.
With Aptana, this kind of stone-age button pecking is over. Aptana has a nice, built-in "Outline" toolbar that helpfully shows all of the functions in the selected file, along with any declared variables. Plus, each More >
Using Spry Data with Thickbox
May 15th
If you've ever tried to use Spry data sets with a default implementation of Thickbox (a jQuery-based version of the familiar Lightbox), you've probably noticed that it doesn't work.
The reason for this, of course, is simple: out of the gates, thickbox.js fires off an initialization function (tb_init) through jQuery's ready(). What this means, technically, is that thickbox has already started its processing and element fishing before Spry's data sets have been fully loaded and rendered. What this means, practically, is that Thickbox won't work.
Though frustrating, there is a fairly simple way to work around this.
Conceptually, what we'll be doing is to bypass jQuery's ready() function and load tb_init manually AFTER we know Spry's data sets have fully loaded and rendered.
First, we need to figure out when the data sets are done processing. This is pretty simple, because Spry comes with a handy way of sniffing this out.
We'll start by setting up a new data region observer. Our observer will watch the data set and when it reaches the "state" that we define, we can manually fire the thickbox.js processing.
So here's our new observer:
the_Observer= new Object()the_Observer.onPostUpdate = function() { // Here's where the thickbox function call will go… };
Spry.Data.Region.addObserver("the_region", the_Observer);
Nothing More >
Checking if Spry eventListener Exists
May 3rd
So if you use Spry, you know that adding an eventListener to anything is super-simple. It's easy to add, and managing the processing that occurs on events is pretty intuitive.
For example:
Spry.Utils.addEventListener("myButton","click",doMyFunction,false);
This one line of code adds an eventListener to the element "myButton" for the onclick event, which will fire "doMyFunction()". And it's just as easy to remove the same eventListener:Spry.Utils.removeEventListener("myButton","click",doMyFunction,false);
Easy enough. However, I recently found myself wanting to not only add and remove eventListeners, but also to check if they exist for certain elements. Luckily, before digging into the DOM to much, I checked SpryDOMUtils.js–sure enough, there's a function already built for this.
In fact, as you may or may not be aware, you can run Spry.Utils.addEventListener() on an element as many times as you like–only one eventListener will be registered. This is because addEventListener() runs a check to see if the eventListener is already registered, and proceeds from there (look at line 166 in SpryDOMUtils.js v. 0.6 to see this in action).
So checking to see if an eventListener is registered for an element is exactly the same as adding and removing the eventListener. Here's what it looks like:
Spry.Utils.eventListenerIsBoundToElement("myButton,"click",doMyFunction,false);
This will return true or false, and you can do whatever you'd More >
Setting Dynamic Mappings in ColdFusion 8
May 2nd
Over the last year, I've learned alot about ColdFusion, AJAX, and DBA stuff. I have to say, however, that the coolest thing I've learned is that in ColdFusion 8 you can set per application mappings in the Application.cfc itself. Why is this so cool? Well, I tend to create a lot of folders in my applications in order to keep related assets in one place together. Of course, creating mappings to these folders makes life a lot easier in that you don't have to worry about making sure you are referencing these folders correctly in different contexts–with mappings ColdFusion can take of that for you.
However, the problem I often run into is that I have to create some funky mapping names in CF Administrator in order to keep them all unique. In my local host environment, for example, the number of mappings is huge and it becomes a hassel to remember to re-set these mappings up when I push final code to a production environment (not to mention that some hosting providers make doing this a lot harder than you could imagine…).
But with CF8, this is no longer a problem. Now you can create dynamic mappings in APplication.cfc, More >
Manipulating Spry Datasets in the DOM
May 1st
I recently created a little peice of functionality using Spry data to setup two lists that can swap data on the fly,
without the need for any postbacks to the server. I've done this thing several times before, but in the past, I've done it very inefficiently. Let me give you an example.
Let's say I'm building a list of songs to put on my mp3 player. I start with a list of all the songs from my media library, as well as a blank list that's waiting to be filled up with songs for the play list. In the past, what I've done is create two Spry data connections to a database, one to manage the play list, and one to manage the full list of songs.
Of course, this is easy enough to do, but I wanted to make it a bit better. For example, when selecting a song, I wanted to be able to show that the song was selected (and also make it un-selectable again).
My past approach would have been to start with an onclick event to handle the data saving. Once this process was complete, I would have fired a complete reload of both my More >