A few days ago I was speaking with Ben Nadel and Rey Bango about a problem I had with jQuery Selectors. I’ve only recently become a bit comfortable with them, but they can still be a bit confusing to use. I wondered if there was a way to create a test script. Currently I’ll write my selector and do hide() (for those of you who don’t use jQuery, you can probably guess that will hide the matched items) or apply a class that adds a border. I’ll do a bunch of “edit/save/alt-tab/reload” tests which isn’t always fun.
With that in mind, I built a simple testing application with jQuery and AIR. When it launches, you are presented with a simple UI:
You can then enter some code:
and switch to the render tab:
Now comes the fun part. You can type a selector value in the form above. As you do, jQuery will attempt to find, and match, the items in your page.
For example, I knew I could match li:first, but wasn’t sure about li:last. Yep, it works:
You can install it here - and hopefully this badge thing will work.
(The badge isn’t working on my blog preview. Folks, if you read this entry immediately after I post it, give me a few if the badge is broken. FYI - badge is definitely wonkey. Use the download link below. Update 7:39PM - badge works now.)
I used Aptana’s AIR support plugin. It is nice, but has a few issues. I was never able to get it to run the AIR application. It wouldn’t error - it just refused to do anything. I used the command line so it wasn’t too bad. It did do a real nice job of laying down the files for a new project. I really appreciate that. It also handled creating the certs/.air file nicely as well.
I’m planning another modification to this soon, based on a suggestion Ben had. I’d also like to allow people to change the ‘highlight’ CSS in case a red border doesn’t make sense.
Shoot, I don’t know if this is useful or not, but, enjoy. :)
p.s. Download the app using the link below. It is a zipped version of the air file. The badge is just not working. Maybe I need to bug the Aptana folks more. :)<p>Download attached file.</p>