JAVASCRIPT - JQuery UI, Combining Sortable with Droppable

I am trying to combine JQuery UI sortable with droppable to create multiple pages for dropping and sorting things. I have setup a blog entry with a stand-along demo here:

http://whit.info/blog/2009/06/06/jquery-ui-combining-sortable-with-droppable/

and here is a jsFiddle:

http://jsfiddle.net/VUuyx/

Note that you can drag to sort the boxes, even into other columns. You can also click the page buttons to switch pages. My problem lies in combining these two features:

By using droppable, I've allowed the user to drag a box to a page button, the page will then switch, and the user can finish dragging it onto the newly revealed page. The problem is that when the page switches, the first column which appears under the dragged box doesn't have it's over event fire. You have to drag to another column, and then back to the first column to get the placeholder to appear.

I'm not sure, but I think I need to somehow clear the events, or fire them manually. The problem seems to stem from the fact that the dragged box is over the column when it is made visible.

Can you assist with this esoteric dilemma?

Thanks!

Update:

So I have been considering possible work arounds for this. Michal suggested firing the refresh method, which indeed doesn't solve the problem, but made me think about event issues.

It seems that when you mouse away and then back again, the proper events fire. Perhaps if I can manually fire the mouseout event for the first column, the reset will allow the mouseover event to fire properly.

I tried this:

$(".column:first").trigger('mouseout'); 

But I don't think that is the same as sortable's out event. Perhaps I should fire that event?

This question and answers originated from www.stackoverflow.com
Question by (8/13/2010 7:39:09 PM)

Answer

At least for the top down drop in I think the solution is somewhere in setting the box class to draggable and link it to the sortable object.

$(".box").draggable({
    tolerance: 'point',
    connectToSortable: '.column',
    snap:false,
    helper : 'clone',
});

This example creates a duplicate of the box but it does allow me to drag box 1 up to page 2 and slowly drag it down above box 5 and get placed into the top spot. It is very sensitive though. You may need to adjust the grids and snap to get it to work consistently for the casual user.

I can certainly imagine that a sortable object wouldn't expect something to come down from the top, because it expects things to be sorted from within the container. Droppable on the other hand expects things to enter from any direction.

Answer by

Find More Answers
Related Topics  javascript  jquery  jquery-ui
Related Questions
  • Working with jQuery UI Draggable, Droppable and Sortable

    I have an ul of draggable items (#doc-editor-options ul li) , an area for dropping those items (#doc-editor-content) and an ul within that area for holding those items (#items-holder) , which is sor…
  • JQuery UI: Cancel Sortable upon Droppable Drop

    I am using JQuery 1.5.1 and JQuery UI 1.8.11. I have added sortable for a number of items - the task here is to allow drag to sort, this all works fine. But I also want to incorporate droppabl…
  • JQuery UI - Drag from Sortable to Droppable

    I have a list of images which are sortable. To delete them, the user will drag them from the Sortable list to a Droppable div representing a trashcan. How can I accomplish this? Do I need to add …
  • jquery UI droppable and sortable not working?

    I searched around and couldn't find a solution to this problem. I am trying to integrate jqueryUI sortable and draggable but I can't seem to get it to work. I have a VERY basic demo here. I've…
  • Sortable and droppable deactivate in jQuery UI

    I have attached jQuery UI sortable and droppable to a few different pages on my page. I want to have the elements that are dropped, not end up in the closest column to the 'droppable' column afte…
  • jQuery UI Sortable + Draggable + Droppable on same elements

    I'm looking to use jQuery UI Sortable + Draggable + Droppable with the same items. I'd like to sort all .item elements and be able to drag and drop an .item into another. Below is my code: <sc…
  • jQuery droppable and sortable with PHP ids

    I am trying to implement jQuery UI droppable and sortable example into one of my PHP scripts... The idea is after user drags and sort out everything to export playlist ids in sorted order and pro…
  • jQuery UI draggable/sortable/droppable disable drop when droppable limit is reached

    JS Bin demo Task: I'm creating an event scheduler using jQuery UI. Events are of a certain length (in minutes) and they can be dragged into different days, each with their own maximum length (…
  • Combining revert with jQuery draggable/droppable

    I'm using the drag and drop plugin with jQuery UI. I'd like to make it so that the draggable container can only be dragged and dropped on the container. In the demonstration: http://jqueryui.com/…
  • jquery.ui sortable issue

    I have created a nested list with drag/drop functionality. My issue is that I want each nesting to sort in itself. For example: -first_level -first_level -second_level -second_level -first_lev…