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

Drag and Drop after last element. #1

Open
CodingNoob opened this issue Jan 22, 2016 · 2 comments
Open

Drag and Drop after last element. #1

CodingNoob opened this issue Jan 22, 2016 · 2 comments

Comments

@CodingNoob
Copy link

Hello. In your demo for sorting photos I am unable to drag a photo to the end of the photo list. It will either go before or back to where it was.

In my scenario it was one image per row so a simple fix was updating the _onDrop function as follows:

_onDrop: function(droppable, ui) {
// Move the dragged item to the new position in the DOM
// and rearrange the items.
// Need to use .detach() to keep the event listeners added
// by jQuery UI.
var draggable = $(ui.draggable);
var movedItem = draggable.detach();

      //put if else check for movedItem.insertBefore() where it only puts the draggable object after
     //if its row id is less than the droppable object's row id
        if(draggable.attr("data-row-id") < $(droppable).attr("data-row-id")){
            movedItem.insertAfter(droppable);
        }
        else{
            movedItem.insertBefore(droppable);
        }
        this.arrange();

        // Trigger event so that third parties have a chance to process the result.
        this._trigger('afterDrop', null, this.element);
    }

Hope this helps. Thanks for the library.

image

@glekli
Copy link
Owner

glekli commented Feb 1, 2016

Thanks for posting this. Great idea to address the issue. I will consider including this in the next release.

@Devdomondo
Copy link

This is a great plugin. There is one thing I cannot figure out. How can I define how many photos per row?
Hope you can help me.
Thanks,
Roberto

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

3 participants