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

  • SEARCH
  • Home
  • 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 9150447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:36:45+00:00 2026-06-17T11:36:45+00:00

After fighting and fightings with this problem, I have no choice but ask for

  • 0

After fighting and fightings with this problem, I have no choice but ask for help! My situation is this: I have a number of absolutely positioned elements. Each of these elements has its own attributes “top” and “left“. The HUGE problem I’m having with this is when I try to sort the items.

$(".container").sortable({
    containment: ".container",
    cursor: 'move',
    items: '.element',
    helper: 'clone',
    placeholder: 'new-placeholder',
    forcePlaceholderSize: true,
    tolerance: 'pointer',
    revert: true,
    scroll: false,
    start: function(event, ui) {
        event.stopPropagation();
        $(".new-placeholder").css("left", ui.helper.position().left);
        $(".new-placeholder").css("top", ui.helper.position().top);
        $(".new-placeholder").css("height", ui.helper.height());
        $(".new-placeholder").css("width", ui.helper.width());
    },
    change: function(event, ui) {
        console.log("Placeholder index: " + ui.placeholder.index());
    }
}).disableSelection();

This is the Current Behavior and this is the Expected behavior

As you can see, the elements should change their position when the dragged element is on over. Is there any better way to do this? I can’t get rid of the absolute positions, that’s the mainly issue. I know the solution have to be on the change, update and stop methods, but I can’t figure this out by myself.

So far, all I got was to get the new index of the placeholder when the item is being dragged over another element but ¿how can I change the position of the placeholder and sort the rest of the elements according to that?

  • 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-06-17T11:36:45+00:00Added an answer on June 17, 2026 at 11:36 am

    It would be impractical to reproduce all the elements, but the basic idea for my own update (to get it to work) was this:

    1. Remove all absolute positioning from the container and the “portlets”

    2. Each sortable container is floated left, is relatively positioned, and has a bottom padding. This padding means that even empty containers can be targeted

    3. Each “portlet” within the container has width set to 100% and is also floated left with relative positioning and a bottom margin (to space them out).

    4. Used the “start” parameter to set my placeholder sizes dynamically. I restrict placeholder size to 350px tall, but for any widgets smaller than that, the placeholder will equal the portlet size.

    5. Used the “connectWith” parameter to link containers.

    Basic HTML:

    <div class="portletContainer"> <!-- floated left, has padding -->
    
      <div class="portlet"> <!-- floated left, margin-bottom, 100% width -->
        <div> some stuff </div>
      </div>
    
      <div class="portlet"> <!-- floated left, margin-bottom, 100% width -->
        <div> some more stuff </div>
      </div>
    
    </div>
    
    <div class="portletContainer">
      <!-- repeat the above pattern; the two containers are then linked -->
    </div>
    

    Basic Sortable JavaScript:

    $('.portletContainer').sortable({
      connectWith: ".portletContainer",
      start: function(e, ui) {
        var elementHeight = ui.item.height();
        if(elementHeight < 350) {
          ui.placeholder.height(elementHeight);
        }
      }
    }); 
    

    If that’s still not working for you, something has likely just been overlooked. Either something is inheriting absolute positioning or JavaScript is adding it.

    I think that covers all the bases, but the even shorter version is: I stripped it back until my markup and CSS was analogous to the markup and CSS in the “portlet” sample in the jQuery UI Sortable Demo page.

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

Sidebar

Related Questions

Have been fighting this for two days and am very frustrated but feel like
After deploying WCF server (svc) on my Server, I have got this message when
I've been fighting this all day. Inside my styles.xml file I have color information
I have an assignment and after hours of pondering and fighting off my illness
I've been fighting this for some time now, and your help will certainly be
I'm fighting with a VBA non-interactive problem that really bugs me: I have a
Another hair-puller. AFter two days of fighting with this I cannot figure out what
After hours of fighting with a script, I narrowed the problem down to the
So, I'm fighting a migraine. I cannot see the solution to this problem. I
I have been fighting with this for days now. I have created my own

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.