Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with an Ember js object and Slip.js #67

Open
zequeira opened this issue Apr 14, 2016 · 1 comment
Open

Problem with an Ember js object and Slip.js #67

zequeira opened this issue Apr 14, 2016 · 1 comment

Comments

@zequeira
Copy link

Hi, very nice plugin btw.
I'm using it on an Ember JS application for Drag & Drop dynamic div elements that reflects an Ember js object.
I face the problem that when taking the first element on the list for putting it as the last element, then the element was duplicated. I found out that your function for "reorder":

list.addEventListener('slip:reorder', function(e) {
    // e.target list item reordered.
    if (reorderedOK) {
        e.target.parentNode.insertBefore(e.target, e.detail.insertBefore);
    } else {
        // element will fly back to original position
        e.preventDefault();
    }
});

when taking any element of the list to move it as last element, e.detail.insertBefore = null and it seems that insertBefore do not handle that situation properly, so I need it to implemented this way:

if (e.detail.insertBefore != null) {
     e.target.parentNode.insertBefore(e.target, e.detail.insertBefore);
} else {
     e.target.parentNode.insertBefore(e.target, e.target.nextSibling);
}

don't know if it's the best approach but I think you should take a look at what is happening when e.detail.insertBefore = null.
Best ;)

@kornelski
Copy link
Owner

If I remember correctly I was assuming that insertBefore(…, null) is the same as appendChild(…)

@zequeira zequeira changed the title Problem with and Ember js object and Slip.js Problem with an Ember js object and Slip.js Apr 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants