Drag table row to a div with jQuery

One of projects I am working on has a long list of classes in a catalog.  These classes are listed on the screen in a table which is sortable and filterable.  Users search through these classes trying to find ones that they want to register for, when the find one they can click on the “add to cart” button in that classes row.  One of the requirements that I was given for this listing was that users should also be able to drag a row to the cart. jQuery UI’s draggables works very nicely but after doing a quick proof-of-concept test I found that draggables don’t work on on table rows very well.  I couldn’t get jQuery UI to drag anything.

If you check out the documentation you will find a option for a “helper”.  This option can either be set to a string (‘clone’ or ‘original’) or you can provide a function which returns the helper object.  So I wrote up some code to create a div with the selected row in a new table.

helper: function(event){
return $('<div class="drag-cart-item"><table></table></div>')
.find('table').append($(event.target).closest('tr').clone()).end().appendTo('body');
},

Then all you need to do is set up a dropable area that knows how to handle that helper.

('#cart').droppable({
drop: function(event, ui) {
var classid = ui.helper.find('tr').attr('id');
var name = ui.helper.find('.name').html();
$('#cart .selected').append('<li id="'+classid+'">'+name+'</li>');
}
});

Check out the working demo



jQuery hover with a fade

@rmurphey sent out a question on twitter yesterday that I got interested in.

#jquery on hover, i want to stop a fade, clear the anim queue, and start an opposite fade — what am i doing wrong? http://bit.ly/QykYd

See it on twitter

All she wanted to do was use the hover event (which lets you define 2 functions one for the mouseenter event and one for the mouseleave event) and start fading an element when you enter and stop and fade back to normal when you leave. The problem was that her code wouldn’t ever fade back.

more




Mozy vs. Backblaze – The fight of the online backup

mozy-vs-backblazeBy now everyone knows that backing up is a very important thing to do. Everyone has had your gut sink to your toes after doing something on your computer and realizing you have no way to undo it. Some times its not your fault the OS just ate your file, or the hard drive just died. No matter what you have on your computer most likely you do not want to take the weeks that it would take to recreate everything on you hard drives. And that is why backup has been a hot topic for the last many years. The first thing to come along was the external hard drive backup, which at first was very flaky, but now with things like Time Machine it as become a turn on and forget about it system.

more



Things iPhone app bug

Just emailed this to Cultured Code because of a bug I was having with their Things app.

I just updated to the Iphone 3.0 OS and also the newest Things app for the iphone that was said to support iphone 3.0. When I open up the iphone app and sync it with the desktop app it opens the sync window on both the iphone and the desktop, goes through the normal process and then when the desktop sync window goes away the iphone is still sitting there syncing. I can let it sit there forever and it will never finish.

Things (Mac): 1.1.2 (941)
Things (iPhone/iPod touch): 1.3.7

I got this response about 5 min later. (very nice turn around time!)

more



To many tweets!

Twitter has really taken off in that pass 6 months. People are signing up like crazy and new tools are popping up like crazy. People are following thousands of others and are trying to find the best way to manage all those tweets. TweetDeck has become one of the leaders as a desktop tool to view all the tweets you are following. The abbility to split the tweets up in to different groups / columns makes it far easier to organize the tweets you really want to read.

more