views:

12

answers:

1

Hi everyone,

Having a slight spot of bother...

I have a draggable element that can be dropped into a sortable list. Ideally I would like to prevent draggable event creating a placeholder in the sortable if the sortable already contains an element with a matching class name of the draggable.

Not had any luck with so looking at removing the draggable once it has been placed in the sortable list using:

beforeStop: function(event,ui)
            {
                var $this = ui.item;
                var person = $this.attr('class').replace(/(.)*a\-(\d*)(.*)/i,'$2');
                if ($this.siblings('.a-'+person).length != 0)
                {
                    $this.remove()
                }

Unfortunatley that makes the intial draggable element no no longer draggable (I may wnat to move it into another sortable in the page so can't have that!) and not sure whether teh beforeStop option is teh most appropriate in this.

Any help you could possibly offer would be very much appreciated.

A: 

You may be able to use the 'accept' option to modify which draggable elements a droppable list will accept:

http://jqueryui.com/demos/droppable/#accepted-elements

Pickle
not really the issue here - more that I could specify the connectToSortable option on draggable start or be able to remove the element inserted into the sortable list with destroying the initial draggable object (could cope with that if I could enable it again)...
ToonMariner