[jQuery] Drag, Drop and Ajax For Photo Album Maker

[jQuery] Drag, Drop and Ajax For Photo Album Maker


MY GOAL:
I'm modifying the Interface 1.2 Shopping Cart to become
a photo picker to create photo albums. I have the basic
drag/drop working. I need to add these using ajax:
-- 'Search photos by tag'
-- 'send photo id to server on drop'
-- 'remove photo id from server on remove'
THE PROBLEM:
I have the separate pieces working, but I'm not sure how
to weave them together (still very new to jQuery). For
example, when I add my 'Search photos by tag' ajax function
to the drag and drop page search works fine, but drag/drop
stops working.
THE CODE:
This is kinda long, hope that's ok. I'll just show
the search function, ask later about the other functions
if I'm still stuck.
My ajax search form and code are in
<div id="searchAlbumPhotos">.
Thumbnails matching the search tag show up in
<div id="theSearchResultImages">.
////////////////////////////////////////////
<script type="text/javascript">
$(document).ready(
function()
{
$('#theSearchResultImages a')
.bind(
'click',
function() {
$(this.parentNode)
.TransferTo(
{
to:addImageToCart(this.parentNode),
className:'transferImage',
duration: 400
}
);
return false;
}
);
$('div.image').Draggable({revert: true, fx: 300, ghosting: true,
opacity: 0.4});
$('#cart').Droppable(
{
accept : 'image',
activeclass: 'activeCart',
hoverclass: 'hoverCart',
tolerance: 'intersect',
onActivate: function(dragged)
{
if (!this.shakedFirstTime) {
$(this).Shake(3);
this.shakedFirstTime = true;
}
},
onDrop: addImageToCart
}
);
}
);
var addImageToCart = function(dragged)
{
var cartItem;
var imageName = $('h2', dragged).html();
var photoID = parseFloat($('span', dragged).html());
var imageId = $(dragged).attr('id');
var imageSrc = $('img',dragged).attr('src');
var isInCart = $('#' + imageId + '_cart');
if (isInCart.size() == 1) {
var quantity = parseInt(isInCart.find('span.quantity').html()) +
0;
isInCart.find('span.quantity').html(quantity
+'').end().Pulsate(300, 2);
cartItem = isInCart.get(0);
} else {
$('#cartImages')
.append('<div class="imageCart" id="' + imageId + '_cart">' +
imageName + '<br />' + '<img src="' + imageSrc + '">' + '<br /><a
href="#">remove</a><br />qty: <span class="quantity">1</span><br /