Skip to Content

Tree Drag and Drop works only once

Hi Friends,

I have a small problem.

I use the code below to move treenodes.

$(document).ready(function() {

$(".sapUiTreeList .sapUiTreeNode").draggable({

drag: function(event) {

selectedId =;



$(".sapUiTreeList .sapUiTreeNode").droppable({

drop : function(event){

var targetId=(this.attributes["data-sap-ui"].value);

test1(event, selectedId, targetId);




But by surprise it works only once. Then I try it the second time, the treenode can not be dragged.

Any clue about this?

Thanks in advance

Rg. Joeg

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Oct 12, 2015 at 04:47 AM

    Hi Joerg,

    Instead of using $(document).ready(function(){}); why not use onAfterRendering?

    Something like this -

    var oTree = new sap.ui.commons.Tree();
         onAfterRendering: function(oEvent){
         //Draggable Code
         //Droppable Code

    Check this sample: JS Bin - Collaborative JavaScript Debugging


    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 11, 2015 at 05:18 PM

    Hi Joerg,

    Where is this code placed? in onInit() or onAfterRendering()

    Add a comment
    10|10000 characters needed characters exceeded

    • HI Kedar

      IMO, Joerg is having different issues from the article.

      Hi Joerg

      Do you create the tree by binding node aggregations to a model? If yes, then you have to update the model and then the tree will re-render. It will not work if you update the tree DOM directly (this is what JQuery drag and drop library does. You need to find the node that is been moved and then after drop, figure out the node before/after it. Then update the model. Unfortunately, It can be complex.


  • Posted on Oct 12, 2015 at 07:53 AM

    Thanks to all for the efforts.

    To Sai, it works like charme by now.

    All the best

    Rg. Joerg.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.