I am doing some html5 / jquery drag and drop functionalities to reorder a set of DOM elements. I now want to change an array of objects that correspond to these DOM elements, but I'm not quite sure how to do it. Here's the javascript:
var draggedIndex = $('.segmentListItem').index($(draggedItem)); var targetIndex = $('.segmentListItem').index($(this)); var playlist = jwplayer().getPlaylist(); //MH - the array for which I want to change the order if (draggedIndex > targetIndex){ $(draggedItem).insertBefore($(this)); //MH - need to move the playlist item at the index of the dragged item before index the target item as well } else { $(draggedItem).insertAfter($(this)); //MH - need to move the playlist item at the index of the dragged item before index the target item as well }