Link to home
Start Free TrialLog in
Avatar of BrentNJ
BrentNJ

asked on

How to get id of destination list when using connectToSortable

I want to disable a source list item when dragged to another list. Using the stop event works ok accept if we accidentally drop the item into itself, then it also becomes disabled.

Would like to check the target list id first, then disable the source element.

This does not work because it references the source list. How do I reference the id of the destination list?

ba is source, aa is destination

Thanks


$('.draggable').draggable({
    connectToSortable: '#aa',
    helper: 'clone',
    revert: 'invalid',
    stop: function(event, ui){
      
      if ($(this).parent().attr('id')=='bs') {
      $(this).draggable({disabled: true}).addClass('done');    
      }
    }
  })

Open in new window

Avatar of jchook
jchook

destination should be in ui argument?
Avatar of BrentNJ

ASKER

Can you point me to the documentation on the ui argument?
ASKER CERTIFIED SOLUTION
Avatar of jchook
jchook

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BrentNJ

ASKER

Thanks.

It took a lot of trial and error.

I'll have to look for docs to explain why it works
receive: function(event, ui) {
				for (i in event)
					$('.debug').append(""+i+"\n");
		  
				alert(event.target.id);
				alert(ui.sender.parent().attr('id'));
				var src=event.target.id;
				var dest=ui.sender.parent().attr('id')
					
				if(src!=dest){
					ui.sender.draggable({disabled: true}).addClass('scored');
				}

Open in new window