0

All, I knew we can implement a draggable to a element just simply call the .draggable method in jquery ui. here is an example for it including connect to sortable.

$(".draggable").draggable({
            helper : function(){
                   //return something dom.},
            cursor : 'move',
            connectToSortable : '.sortableLayoutSection'});

$(".sortableLayoutSection").sortable({
            appendTo : parent,
            containment : "parent",
            cursor : "pointer",
            placeholder : 'li-placeholder',
            forcePlaceholderSize : false
        });

But my question is how can I known the draggable item really drop into the specified container(in this example is element with class named .sortableLayoutSection)? thanks.

Updated

$(".sortableLayoutSection").sortable({
                appendTo : parent,
                containment : "parent",
                cursor : "pointer",
                placeholder : 'li-placeholder',
                forcePlaceholderSize : false,
                receive: function( event, ui ) {alert('ok.got something.')}
            });
Cœur
  • 37,241
  • 25
  • 195
  • 267
Joe.wang
  • 11,537
  • 25
  • 103
  • 180

2 Answers2

1

first you should init your sortable element as droppable element too, while please refer to this:http://api.jqueryui.com/droppable/#event-drop. it has drop event, it means that there is a drag element has been drag in to droppable. so you can write the function to determine what you want to do.

OQJF
  • 1,350
  • 9
  • 12
0

The answer is here, After I test it , It solve my problem, only drop in the specified container will trigger a event named receive,please review my updated content .thanks.

Community
  • 1
  • 1
Joe.wang
  • 11,537
  • 25
  • 103
  • 180