selector not recognising addClass

selector not recognising addClass

Fellow jQuerians,

I'm trying to write a cinema seat selection page and I'm hitting a problem with a selector not recognising a 'booked' class that I've just been added via JSON. I wonder if anyone could tell me why it works ok when I hard code the 'booked' class in but not when I do it through jQuery. Should I just do it in PHP??? or is there a way around the problem. Thanks in advance for your help.

// So here I call my PHP to grab the booked seats and update the class, which works fine.//


$.getJSON('showseat.php', show, processSeat);
function processSeat(data){
    $.each(data, function(objId, seatInfo){
    $('#selected_show').append('<p>' + seatInfo.seat_id + '</p>');
    var seatId = '#' + seatInfo.seat_id;
    $(seatId).addClass('booked');
    }); // end each
} // end processData

// Then, I want to select ONLY those without a 'booked' class but for some reason it does not recognise the seats that have just added the class="booked" too. ??? //  

// Add click listener to seats
    $('#theatre a:not(.booked)').toggle(
    function(){
        $(this).addClass('selected');
        $('#selected_show').append('<p class="' + $(this).attr('title') + '">' + $(this).attr('title') + '</p>');
       
        },
        function(){
        $(this).removeClass('selected');
        var deselect = 'p.' + $(this).attr('title');
        $(deselect).hide();
        }
    ); // end of toggle

Can anyone tell me why that is? and what I can do to resolve it?

Mucho grasias.

J

code well.