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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:55:58+00:00 2026-05-12T08:55:58+00:00

Below is my full code for my site’s drag and drop, that saves positions

  • 0

Below is my full code for my site’s drag and drop, that saves positions into mysql
This is a couple years old though and I would like to update my jquery to a newer version.

This code uses the older jquery version 1.0.2 and interface.js

I believe to use drag and drop with jquery’s newer versions requires the use of jquery UI plugin?

Can someone who understands javascript/jquery help me to get this working with a newer version, when I try using new versions of jquery with it, it will not work

<script type="text/javascript" >
var USER={"ID":"<?php echo $uid; ?>"};

var _x;
var _y;
var _pos;
if(document.all){document.body.onload=b_onload;}
else{document.body.setAttribute("onload","b_onload()");}
function b_onload(){
    $('#columns td.portlet_td').each(function(i){
        $(this).children("br").remove();
    });
    $('#columns td.portlet_td').Sortable(
        {
            accept: 'portlet',
            helperclass: 'sort_placeholder',
            activeclass :   'sortableactive',
            opacity: 0.7,
            tolerance: 'touch',
            handle:'.drag-handler',

            onStop:function(){

                var x = getPos();

                if(!$("#lgif").get(0)){
                    $('<i'+'mg id="lgif" src="images/loading.gif" style="display:block;position:absolute;top:500px;left:50%;" />').appendTo('body');
                }

                var __top = (document.body && document.body.scrollTop)?(document.body.scrollTop):((document.documentElement && document.documentElement.scrollTop)? document.documentElement.scrollTop: 0);

                $("#lgif").css({top:__top+'px'});

                $("#lgif").show();
$.getJSON(
    '/processing/ajax/HOMEsaveposition.php',
    {
        uid:(USER.ID),
        position:x
    },
    function(json){
        $("#lgif").hide();
    }
);
            }
        }
    );



};

function getPos(){
    _pos="";
    $('#columns td.portlet_td').each(function(i){
        _x=i;
        $(this).children(".portlet").each(function(j){
            _y=j;
            var index = this.getAttribute("id").split('id')[1] - 100;
            var pos=_x+":"+index;
            _pos+=pos+"|";
        });
    });
    return _pos;
}
</script>
  • 1 1 Answer
  • 1 View
  • 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-12T08:55:58+00:00Added an answer on May 12, 2026 at 8:55 am

    Couple of improvements (I’m sure that’s not all but should help you start)

    I would just replace that:

    if(document.all){document.body.onload=b_onload;}
    else{document.body.setAttribute("onload","b_onload()");}
    

    with

    $('body').load(b_onload);
    

    Next inside of your b_onload() method you could replace:

    $('#columns td.portlet_td').each(function(i){
        $(this).children("br").remove();
    });
    

    with

    $('#columns td.portlet_td br').remove();
    

    As for the sortable you could use jQuery UI Sortable. It’s hard to just tell how exactly should you use it but there’s a lot of examples and I’m sure you will find those who will be close to your desired behavior and you can easily adapt them for your app. jQuery UI has quite nice documentation.

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

Sidebar

Related Questions

No related questions found

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.