Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3666942
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:56:27+00:00 2026-05-19T01:56:27+00:00

I am looking for way to be able to drop in a div and

  • 0

I am looking for way to be able to drop in a div and the droped item automatically go and join the sortable ‘ul’ there. There is only one drop enabled ul in the entire div.
I am using sortable in jQuery.

I need the entire div that’s containing the sortable ul to be drop area.


flexi comment box

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:56:28+00:00Added an answer on May 19, 2026 at 1:56 am

    It took me a while but I figured it out myself… Maybe I can save someone else the pain, so here goes…

    just convert the div into a draggable and in drop event function add the dragged item in the children of the target list.
    It is not that easy since when dragging the physical dragged element(object) ist not available programmtically with all its attributes. You just seem to get the text in attributes and not even the id.
    My idea was to save the id of the element on mouse down event when dragging starts. then I created the complete list item giving the text from the dragged item text and giving it the id that I saved earlier. in mouse down event at the start of the process.


    Setting mouse-down event on the draggable element (in my case a list item) ##

    When the mouse is first down on the draggable element (that is when the dragging event starts) I capture the id of the element, since I need the element’s id to be able to add it to the database running at backend.

    <li align="left" onmousedown="mouseDown(this)" id="1832" class="ui-state-default">Advanced Econometrics II | E 805</li>
    

    Mouse Down function saving the id of the dragged item

    Maybe it is important to mention that you should not initialize the variable dragged_course_id with the word ‘var’ before it, because if you do the variable will become local and won’t be available in the drop event function at the end of the drag process.

    function mouseDown(item)
    {
        dragged_course_id = item.id;
    //  alert (dragged_course_id);
        }
    

    Droppable Div Configuration

     $(function() {
            $( "#droppable" ).droppable({
                activeClass: "greedy",
                hoverClass: "over_state",
                drop: function( event, ui )
                 {
                    $( this ).removeClass("over_state");
                    target_stack = document.getElementById('sortable2');
                    var already_selected_courses = target_stack.childNodes;
                    ignore=false;
                    for (i=0;i<already_selected_courses.length; i++)
                    {
                        if (dragged_course_id == already_selected_courses[i].id) ignore=true;
                    }
                    if (!ignore) $( "<li align='left' class='ui-state-default' id= "+dragged_course_id+"></li>" ).text( ui.draggable.text() ).appendTo( target_stack);
    
                    available_stack = document.getElementById('sortable1').childNodes;
    
                    for (i=0; i<available_stack.length;i++)
                        if (available_stack[i].id == dragged_course_id) available_stack[i].parentNode.removeChild(available_stack[i]);
    
    
                },
    
    
    
    
                        out: function(event, ui)
                         {
                              $(this)
                        .removeClass('over_state')
                        .removeClass('greedy')
                         }  
    
    
            });
        });
    

    This turned out to be fine but then there was this problem of the list itself being dropable. When an item was dropped on the div it drop event would trigger but when the element was dropped on the list itself then both the drop events would trigger, adding the dragged item twice. For that I came up with this cheeky (not particularly beautiful) idea: I remove the last element of the in the receive event of target sortable!


    Target Sortable Configuration ##

    $( "#sortable2" ).sortable({
                greedy: 'true',
                connectWith: ".connectedSortable",
                cancel: ".ui-state-disabled",
                items: "li:not(.ui-state-active)",  
                receive: function(event,ui)
                {
                     target_stack = document.getElementById('sortable2');
                     target_stack.removeChild(target_stack.lastChild);
                },
                dropOnEmpty: false
            });
    

    Flexi Comment Box

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I am looking for a way to run a test that is able
I'm looking for way to PHP to detect if a script was run from
I am using the jquery-ui-dialog plugin I am looking for way to refresh the
I looking for a way, specifically in PHP that I will be guaranteed to
I looking for a way to programmatically start a VOIP call using the SIP
I'm looking for some way to effectively hide inherited members. I have a library
I'm looking for any way that I can improve the selector performance of a
I'm looking for a way to poll different servers and check that SQL server
I'm looking for a way to delete a file which is locked by another
I'm looking for a way to visually mark or tag a window (any OS)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.