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 5928555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:18:20+00:00 2026-05-22T14:18:20+00:00

I have a sortable list of items that returns results based on what the

  • 0

I have a sortable list of items that returns results based on what the user types in the search box. The results always overflows and here i am using the following css for it:

#list { overflow-x: visible; overflow-y: hidden; }

This allows me to have only a vertical scrollbar. I then drag the individual li’s that are in the list over to a droppable area. The sortable functionality is added to the list using the JQuery below:

$("#list").sortable({
   connectWith: ".connectedSortable",
   helper: 'clone',
   appendTo: 'body',
   zIndex: 999
});

The reason i use the appendTo: ‘body’ is to ensure that the item that is being dragged is on top of everything and will not be under the list’s other items when being dragged. However, whenever I drag any item from the list, the DIVs that are in the item will have their CSS styling gone.

I understand that this is due to the fact that when the item is dragged, it is appended to ‘body’ and thus does not have any parent to inherit the original CSS styles.

My question is how do i style the dragged item back to its original styling to make sure it stays the same even if I am dragging/not dragging it? through the events?

EDIT:

Found the reason for the css messing up. It was a random br thrown in between two div’s causing it to be interpreted differently when the item was being dragged and appended to the body.

  • 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-22T14:18:21+00:00Added an answer on May 22, 2026 at 2:18 pm

    You have two options to sort the problem. One is to create your own helper with the function. This way you can style is any way you want, wrap it in an element, add classes, etc.

    The following demo shows the difference, the top one works, the bottom one is broken. http://jsfiddle.net/hPEAb/

    $('ul').sortable({
        appendTo: 'body',
        helper: function(event,$item){
            var $helper = $('<ul></ul>').addClass('styled');
            return $helper.append($item.clone());
        }
    });
    

    The other option is not to use append:'body', but to play with zIndex. Your zIndex:999 clearly has no effect, since the default value is 1000. 🙂 The problem with zIndex is that it only matters for siblings, elements within the same parent. So if you have another sortable on your form with a greater zIndex than your current sortable, its items could easily be on top of your dragged one, regardless of the zIndex of your currently dragged item.

    The solution is to push your whole sortable on top when dragging starts and restore it when it stops:

    $('#mySortable').sortable({
        start: function(){
            // Push sortable to top
            $(this).css('zIndex', 999);
        },
        stop: function(){
            // Reset zIndex
            $(this).css('zIndex', 0);
        }
    });
    

    If the original value matters, you can even save the original zIndex with .data() and retrieve it afterwards.

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

Sidebar

Related Questions

I have a sortable list that updates my database when items are shifted around.
I have an unsorted list ( UL ) that contains sortable list items (
I have a nested sortable list that can have items dynamically added or removed
i have a form and a sortable() list where a user can drag from
I have list items in an unordered list that when double clicked, can be
i have three list that all of them are connected with jquery-ui sortable, first
I have a list of tasks that I allow a user to sort, currently
I have a page where i have a sortable list of items (a div
I have a list of items that I need to record its position in
I'm building a jQuery sortable list where the user can add items from a

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.