Lee Kelleher’s Weblog

Just another WordPress.com weblog

Archive for the ‘pez’ tag

Introducing Pez…

with one comment

In between my many projects (paid and personal) and entering fatherhood… I seem to have found some time to start up an open-source project with Ben Taylor, (my old comrade from the Scream days).

I’ve mentioned it a couple of times on my blog recently, but hadn’t yet got around to introducing it… then Ben beat me to it!

So without further ado, here is Ben’s introduction to Pez!

Written by Lee Kelleher

March 9th, 2008 at 11:04 am

Posted in blog

Tagged with , , , , ,

Accessing the jQuery DOM in an Ajax callback

without comments

Whilst developing the admin pages for Pez, I wanted to add some nice features to the UI. My first choice for a JavaScript framework is jQuery. I’ve used other frameworks before, (like mootools, script.aculo.us and YUI), but I just seem to get on better with jQuery, (although mootools is a very close second).

Last night I was playing around with the Ajax/jQuery.get() method - it was the first time I’d used it, and was having some difficulty understanding how access the jQuery DOM object in the callback function.

At first I was taking the wrong approach, I was trying to do this all in the onClick event of an anchor link:

onclick="javascript:$.get('index.php', { key: $('#source-input-id').val() }, function(data){ $('#target-input-id').val(data); });"

But that didn’t work … and I’m not fully sure why … but anyway, I carry on …

I started to look at the this keyword to see if that would help. Learning jQuery’s What is this? post clarified a lot of my confusions, (in that with the Ajax callbacks, the this keyword/object is outside the jQuery DOM, but contains details of the call itself), however I was still no closer to the solution I wanted.

At this point I changed how I was using the $.get() method. I created a wrapper function for jQuery calls:

function get_value()
{
    $.get('index.php', { key: $('#source-input-id').val() }, function(data){
        $('#target-input-id').val(data);
    });
}

This approach meant that I could reference the jQuery DOM object from within the Ajax callback function.

There is probably a hundred other ways of doing this using jQuery - or could be even simpler with another JS framework - but I got it working nicely in the end… Happy Days!

Written by Lee Kelleher

March 8th, 2008 at 2:13 pm

Posted in blog

Tagged with , , , ,

Fatherhood

with one comment

lazy day

I’ve survived the first week of fatherhood! Even after all the advice from friends and family, books you’ve read, etc… Nothing prepares you for it! Completely in at the deep-end on the first sleepless night - no idea what was going on; what time it was; night-turns-into-day-into-night; a total blur! Strangely though, I am loving being a father - and absolutely smitten with Katelyn!

In other news, there’s another baby (a project) that Ben and I are getting the ball rolling with… Pez!
We’ll tell you all about it soon!

Written by Lee Kelleher

February 24th, 2008 at 8:38 pm

Posted in blog

Tagged with , , , , , ,