Drag/Drop with conditions

Drag/Drop with conditions


Hi,
I'm new to the drag/drop stuff in jQuery UI and am finding it really
useful. My problem is that I need to be able to apply conditions upon
drop to decide whether or not to append the dragged element to the
droppable div. At the moment I have a simple drop function:
$(".dropBox").droppable({
                accept: ".dragableBox",
                drop: function(ev, ui) {
                    var theId = ui.draggable.clone().attr("id");
                    document.getElementById('dropShipment').innerHTML=$
(this).attr("id"); // set the div value for shipment used by
sizeselector form to add to user session
                    //alert("theId "+theId+" shipment id "+$(this).attr("id")+"
dropShipment "+document.getElementById('dropShipment').innerHTML);
                    var idnum = theId.substring(3);
                if(theId.substring(0,3) == 'box') {
                        openTB('sizeSelector'+idnum);
                        ui.draggable.clone().fadeOut("fast",
                        function() {
                            $(this).fadeIn("fast")
                        }).appendTo($(this)); //
                    }
                }
            });
What I need to do is to check the value of a counter, say shipCount,
and only show the thickbox and append the draggable element IF the
value is less than 2. How would I code this with jQuery-compatible
javascript?
Thanks for any help!