Note that there are some explanatory texts on larger screens.

plurals
  1. POItem of sortable element loses its CSS styles when it is being dragged? (If appendTo: 'body')
    primarykey
    data
    text
    <p>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:</p> <pre><code>#list { overflow-x: visible; overflow-y: hidden; } </code></pre> <p>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:</p> <pre><code>$("#list").sortable({ connectWith: ".connectedSortable", helper: 'clone', appendTo: 'body', zIndex: 999 }); </code></pre> <p>The reason i use the <strong>appendTo: 'body'</strong> 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.</p> <p>I understand that this is due to the fact that when the item is dragged, it is appended to <strong>'body'</strong> and thus does not have any parent to inherit the original CSS styles.</p> <p>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?</p> <p><strong>EDIT:</strong></p> <p>Found the reason for the css messing up. It was a random <strong>br</strong> thrown in between two <strong>div's</strong> causing it to be interpreted differently when the item was being dragged and appended to the body.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload