ObaidUrRehman / ng-drag-drop

Drag & Drop for Angular - based on HTML5 with no external dependencies. :tada:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to add the element at specific index in dropped items.

opened this issue · comments

Hi,
I want to add the element to a specific position in the list (i.e. in between element 'A' and 'B' I want to add element 'X'). But in the onDrop event, I'm not getting anything like the index to add the element into specific position at "dropped items"

can anybody tell me how to add an item to a specific index of dropped items?

This feature is currently in development. Closing as Duplicate of #12

Hi ObaidUrRehman,
Thanks for your updated. I have resolved this issue.

Steps:

  1. I'm getting closest element where I drop the element.
    var id = element.nativeEvent.target.closest('li').getAttribute('Id');
  2. im find the index of the item in list and pushing item into list from "element.dragData"
    this.ListItems.splice(i, 0, element.dragData);