This is a migrated thread and some comments may be shown as answers.

When I drop it over the target, how do I make it stay there?

1 Answer 92 Views
Drag and Drop
This is a migrated thread and some comments may be shown as answers.
Joe Sugden
Top achievements
Rank 1
Joe Sugden asked on 14 Mar 2012, 02:17 PM
And disappear from original position?
And then move it inside the target from one spot to another?

1 Answer, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 25 Mar 2012, 06:20 AM
Can you post code?

This method seems a bit like smoke and mirrors and there may be a better way (and if there is I hope someone shares :)), but you can try the following:

$('#foo').kendoDraggable({
  hint: $('#foo').clone(),
  dragstart: function () {
    $('#foo').hide()
  },
  ...
})
  
$('body').kendoDropTarget({
  drop: function (e) {
    $('#foo')
      .show()
      .offset({
        top: e.clientY,
        left: e.clientX
      })
  }  
})

In this example I use the 'body' as the drop target and use absolute positioning to determine the final resting place of '#foo' once I drop it.  To give the illusion that I'm dragging '#foo', I clone it (for the drag), hide it while dragging, and then show it again once it's been dropped.

Hope this has helped!
Tags
Drag and Drop
Asked by
Joe Sugden
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Share this question
or