Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Sortable based on LEFT CSS property on horizontal list
    primarykey
    data
    text
    <p>I implemented a sortable horizontal list. I would like to update LEFT css values of each element in the list (all elements are div). Because <strong>left</strong> property is very important for us, we should keep it. I couldn't find a way how to do it. </p> <p>Currently, because of the hardcoded left values, sortable list cannot be ordered. It always become same. When a user start dragging any item, Left values should be changed automatically, so the user will see the items are replacing.</p> <p>Here is my example:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;jQuery UI Sortable - Default functionality&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-1.8.3.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"&gt;&lt;/script&gt; &lt;style&gt; div { display: block; } div.item { position: absolute; overflow: hidden; height: 64px; background-color: gray; border: 1px solid black; float: left; } #test { position: fixed; top: 70px; left: 10px; } &lt;/style&gt; &lt;script&gt; $(function() { $("#sortable").sortable({ placeholder: "placeholder", start : function(event, ui) { var wid = parseInt(ui.item.width()); ui.item.data('orgWid', wid); }, sort : function(event, ui) { var wid = ui.item.data('orgWid'); $('#test').text(wid); /** * Here we should update the "left" css value of each element on list. //for siblings of selected div $(".placeholder ~ div").each(function() { $(this).css("left", parseInt($(this).css('left')) + wid); } **/ }, cursor : 'crosshair' }); $("#sortable").disableSelection(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;div id="sortable"&gt; &lt;div id="item_0" class="item" style="left: 0px; width: 176px;"&gt;176px&lt;/div&gt; &lt;div id="item_1" class="item" style="left: 176px; width: 292px;"&gt; 292px&lt;/div&gt; &lt;div id="item_2" class="item" style="left: 468px; width: 85px;"&gt;85px &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p id="test"&gt;-&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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