1

I am trying to drag an element from out site of kendoSortable and drop it into kendoSortable.

I set connectWith property of kendoSortable. But it`s not working.

In Kendo UI demo i did not find this kind of example.

Here is my Code :

<h1>Sortable</h1>


<ul id="sortable">
      <li class="list-item">Apples</li>
      <li class="list-item">Grapefruits</li>
      <li class="list-item">Bananas</li>
  </ul>

  <h1>Dragable</h1>
  <ul id="dragable">
      <li class="list-item">D1</li>
      <li class="list-item">D2</li>
      <li class="list-item">D3</li>
  </ul>

 <script>
     $("#sortable").kendoSortable({
        connectWith: "#dragable",
        placeholder: function placeholder(element) {
            return $("<li class='list-item' id='placeholder'>Drop Here!</li>");
        },
    });

     $("#dragable li").kendoDraggable({
        hint: function () {
            return $("<li class='list-item' id='placeholder'>GOOOOOO!</li>");
        }
    });

    $("#sortable").kendoDropTarget({
        dragenter: function () {
            console.log("enter");
        },
        dragleave: function () {
            console.log("leve");
        },
        drop: function (e) {

        }
    });
  </script>

In dojo.telerik

4

1 回答 1

1

鉴于您的两个列表:

<h1>Sortable</h1>
<ul id="sortable">
  <li class="list-item">Apples</li>
  <li class="list-item">Grapefruits</li>
  <li class="list-item">Bananas</li>
</ul>

<h1>Dragable</h1>
<ul id="dragable">
  <li class="list-item">D1</li>
  <li class="list-item">D2</li>
  <li class="list-item">D3</li>
</ul>

并假设您要将其从第二个 ( #draggable) 复制到第一个 ( #sortable) 中,您应该connectWith在第二个(副本的来源)中定义什么:

  $("#sortable").kendoSortable({
      placeholder: function placeholder(element) {
          return $("<li class='list-item' id='placeholder'>Drop Here 1!</li>");
      }
  });

  $("#dragable").kendoSortable({
      connectWith: "#sortable",
      placeholder: function placeholder(element) {
          return $("<li class='list-item' id='placeholder'>Drop Here 2!</li>");
      }
  });

同样重要的是要注意placeholder可能在两者中都定义。当您从该列表中移动时使用第一个,而当原点位于第二个列表中时使用第二个(无论放置是第一个还是第二个)。

你可以在这里看到它:http: //dojo.telerik.com/@OnaBai/oJIy

于 2014-08-17T22:16:51.643 回答