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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:19:48+00:00 2026-05-13T09:19:48+00:00

This is what I have so far. The code I have is contained in

  • 0

This is what I have so far.
The code I have is contained in php so there is some php in it.

$(document).ready(function() {
    $(\"ul.droptrue\").sortable({
        connectWith: '.droptrue',
        remove:function(event, ui){ 
              var order = $(ui.item).serialize; 
              alert( order );
        },
        receive : function () {
          var order = $(this).sortable('serialize');
                  var list = 'list[]='+this.id+'&list[]=".$module[1]."&';
                  $.ajax({
                    type: 'POST',
                    url: '".__BASE_URL."modules/admin/moduleUpdate.php',
                    data: list+ order,
                    success: function(msg){alert(msg);},
                    error: function(msg){alert( \"Data Error: \"
+ msg );}
                  });
      }
    }); });

So what I am trying to do is get a serialized version of the ui.item. With the receive section I get an output of “listItem[]=3&listItem[]=4…” but with the ui.item I get “function () {return o.param(this.serializeArray());}”.

How do I get a serialized version of ui.item?

  • 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-13T09:19:48+00:00Added an answer on May 13, 2026 at 9:19 am

    I figured out what I was doing wrong. So this question does not need anymore help.

    A brief summary of what I did.

    I used the update function of the sortable and then I used php to determine what is being change and how to change it.

    Here is the jquery code:

        $('ul.droptrue').sortable({
        placeholder: 'ui-state-highlight',
        connectWith: '.droptrue',
      update : function (event, ui){
    
            //vars needed
            var sender = null;
            var item = ui.item.context.id;
            var target = event.target.id;
    
            var order = $(this).sortable('serialize');
    
            if(ui.sender != null){
                sender = ui.sender.context.id;
            }
            $.ajax({
                type: 'POST',
                data: 'list[]='+this.id+'&list[]='+item+'&list[]=".$dirt[1]."&list[]='+sender+'&'+order,
                url: 'modules/admin/moduleUpdate.php'
            });
      }
    });
    

    Here is the php I used:

    $widgetParts = explode('_', $_POST['list'][1]);
    $widget = $widgetParts[1];
    
    switch ($_POST['list'][0]) {
    case 'header_layout':
        if($_POST['list'][3] == 'null'){
            if(isset ($_POST['listItem'])){
                if(in_array($widget, $_POST['listItem'])){
                    foreach ($_POST['listItem'] as $key => $value) {
                        $sql = "UPDATE widget_layouts SET weight=".$key." WHERE module_id=".$_POST['list'][2]." AND position=1 AND widget_id=".$value;
                        mysql_query($sql);
                    }
                }
            }else{
                    $sql = "DELETE FROM widget_layouts WHERE module_id=".$_POST['list'][2]." AND widget_id=".$widget." AND position=1";
                    mysql_query($sql);
                }
    
        }else{
            foreach ($_POST['listItem'] as $key => $value) {
                $sql = 'SELECT * FROM widget_layouts WHERE  module_id='.$_POST['list'][2].' AND widget_id='.$value.' AND position=1';
    
                if(mysql_num_rows(mysql_query($sql)) == 0){
                    $sql = "INSERT INTO widget_layouts VALUES (".$_POST['list'][2].",".$widget.",1,".$key.")";
                    mysql_query($sql);
                }
            }
        }
    
        break;
    case 'content_layout':
        if($_POST['list'][3] == 'null'){
            if(isset ($_POST['listItem'])){
                if(in_array($widget, $_POST['listItem'])){
                    foreach ($_POST['listItem'] as $key => $value) {
                        $sql = "UPDATE widget_layouts SET weight=".$key." WHERE module_id=".$_POST['list'][2]." AND position=2 AND widget_id=".$value;
                        mysql_query($sql);
                    }
                }
            }else{
                    $sql = "DELETE FROM widget_layouts WHERE module_id=".$_POST['list'][2]." AND widget_id=".$widget." AND position=2";
                    mysql_query($sql);
                }
        }else{
            foreach ($_POST['listItem'] as $key => $value) {
                $sql = 'SELECT * FROM widget_layouts WHERE  module_id='.$_POST['list'][2].' AND widget_id='.$value.' AND position=2';
                if(mysql_num_rows(mysql_query($sql)) == 0){
                    $sql = "INSERT INTO widget_layouts VALUES (".$_POST['list'][2].",".$widget.",2,".$key.")";
                    mysql_query($sql);
                }
            }
        }
        break;
    case 'sidebar_layout':
        if($_POST['list'][3] == 'null'){
            if(isset ($_POST['listItem'])){
                if(in_array($widget, $_POST['listItem'])){
                    foreach ($_POST['listItem'] as $key => $value) {
                        $sql = "UPDATE widget_layouts SET weight=".$key." WHERE module_id=".$_POST['list'][2]." AND position=3 AND widget_id=".$value;
                        mysql_query($sql);
                    }
                }
            }else{
                    $sql = "DELETE FROM widget_layouts WHERE module_id=".$_POST['list'][2]." AND widget_id=".$widget." AND position=3";
                    mysql_query($sql);
                }
        }else{
            foreach ($_POST['listItem'] as $key => $value) {
                $sql = 'SELECT * FROM widget_layouts WHERE  module_id='.$_POST['list'][2].' AND widget_id='.$value.' AND position=3';
                if(mysql_num_rows(mysql_query($sql)) == 0){
                    $sql = "INSERT INTO widget_layouts VALUES (".$_POST['list'][2].",".$widget.",3,".$key.")";
                    mysql_query($sql);
                }
            }
        }
        break;
    case 'footer_layout':
        if($_POST['list'][3] == 'null'){
            if(isset ($_POST['listItem'])){
                if(in_array($widget, $_POST['listItem'])){
                    foreach ($_POST['listItem'] as $key => $value) {
                        $sql = "UPDATE widget_layouts SET weight=".$key." WHERE module_id=".$_POST['list'][2]." AND position=4 AND widget_id=".$value;
                        mysql_query($sql);
                    }
                }
            }else{
                    $sql = "DELETE FROM widget_layouts WHERE module_id=".$_POST['list'][2]." AND widget_id=".$widget." AND position=4";
                    mysql_query($sql);
                }
        }else{
            foreach ($_POST['listItem'] as $key => $value) {
                $sql = 'SELECT * FROM widget_layouts WHERE  module_id='.$_POST['list'][2].' AND widget_id='.$value.' AND position=4';
                if(mysql_num_rows(mysql_query($sql)) == 0){
                    $sql = "INSERT INTO widget_layouts VALUES (".$_POST['list'][2].",".$widget.",4,".$key.")";
                    mysql_query($sql);
                }
            }
        }
        break;
    case 'widget_layout':
       foreach ($_POST['listItem'] as $key => $value) {
            $sql = "DELETE FROM widget_layouts WHERE module_id=".$widget." AND widget_id=".$value;
            $query = mysql_query($sql) or die(mysql_error());
       }
        break;
     }
    

    These pieces of code allow me to create a drag and drop list to dynamically layout my website without any hassle. I hope these pieces of code could help someone out that is having the same type of problem that I was having.

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

Sidebar

Ask A Question

Stats

  • Questions 349k
  • Answers 349k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer One nice solution is to create a distinct project with… May 14, 2026 at 6:55 am
  • Editorial Team
    Editorial Team added an answer My redmine (ruby, webrick) is too very slow. Now I… May 14, 2026 at 6:55 am
  • Editorial Team
    Editorial Team added an answer Try implementing the delegate method for NSURLConnection - (void)connection:(NSURLConnection *)connection… May 14, 2026 at 6:55 am

Related Questions

I am pretty new to php and could sure use some help understanding how
I'm trying to flip between two views. That's easy, the code is below, but
I have a DataGridView with two DataGridViewComboBoxColumns. I want to use the selected item
I have a DataGridView that has a class as its DataSource. The class contains
I want to reload a page so that it does not cause the effects

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.