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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:27:24+00:00 2026-06-13T11:27:24+00:00

Please Skip to Update #2 at the Bottom if you don’t want to read

  • 0

Please Skip to Update #2 at the Bottom if you don’t want to read the whole post.

I have created a customizable UI using jquery-ui connected lists:
http://jqueryui.com/sortable/#connect-lists

I now want to save the user’s configuration of the UI to a cookie on their local machine so that the next time they load the page the layout they previously setup will be loaded, as discussed on this page:
http://devheart.org/articles/jquery-customizable-layout-using-drag-and-drop/

The problem is that after discussing how to save the custom configuration of multiple connected lists in part 2 of his writeup, he neglects to include multiple connected lists in part 3 where he implements the code into an actual design. I have been able to get everything on my page to work like the final example on that page, but whenever I try to modify the code to work with connected lists the page no longer works.

I understand the basic idea behind what the code is doing, but I don’t know JavaScript and have had no success in modifying the code to work with connected lists. I’m hoping that someone who does know JavaScript will be able to easily modify the code below to work with connected lists like part 2 does.

Part 2 saves the order of multiple connected lists, but doesn’t load external html pages with the corresponding name.

Part 3 loads external html pages with the corresponding names of the item, but only supports a single list.

Code for Connected Lists from Part 2:

// Load items
function loadItemsFromCookie(name)
{
    if ( $.cookie(name) != null )
    {
        renderItems($.cookie(name), '#wrapper');
    }
    else
    {
        alert('No items saved in "' + name + '".');
    }
}

// Render items
function renderItems(items, container)
{
    var html = '';
    var columns = items.split('|');

    for ( var c in columns )
    {
        html += '<div class="column"><ul class="sortable-list">';

        if ( columns[c] != '' )
        {
            var items = columns[c].split(',');

           for ( var i in items )
            {
               html += '<li id="' + items[i] + '">Item ' + items[i] + '</li>';
            }
        }

        html += '</ul></div>';
    }

    $('#' + container).html(html);
}

Code from part 3 that does not support connected lists (Trying to modify this to support connected lists):

// Get items
function getItems(id)
{
return $('#' + id + '-list').sortable('toArray').join(',');
}

// Render items
function renderItems(id, itemStr)
{
    var list = $('#' + id + '-list');
    var items = itemStr.split(',')

    for ( var i in items )
    {
        html = '<li class="sortable-item';

        if ( id == 'splash' )
        {
            html += ' col3 left';
        }
        html += '" id="' + items[i] + '"><div class="loader"></div></li>';
        list.append(html);

        // Load html file
        $('#' + items[i]).load('content/' + items[i] + '.html');
    }
}

Update #1:

I think I almost have it, I just can’t get it to insert html from the external html files. It was able to get it to insert variables and plain text, just not the external html.

// Render items
    function renderItems(items)
    {
        var html = '';

        var columns = items.split('|');

        for ( var c in columns )
        {
            html += '<div class="column';

            if ( c == 0 )
            {
                html += ' first';
            }

            html += '"><ul class="sortable-list">';

            if ( columns[c] != '' )
            {
                var items = columns[c].split(',');

                for ( var i in items )
                {
                    html += '<li class="sortable-item" id="' + items[i] + '">';

                    //---------This Line Isn't Working--------->
                    $('#' + items[i]).load(items[i] + '.html');
                    //---------This Line Isn't Working--------->

                    html += '</li>';
                }
            }

            html += '</ul></div>';
        }

        $('#example-2-3').html(html);
    }

Update #2:

I’ve been looking up exactly what each JavaScript command in the example does and I think I’ve figured out the problem. I can’t just load the page, I need to append the code from the external page to the html variable. I think I need to use the .get command, something like:

var pagedata = '';
.get(items[i] + '.html', function(pagedata); 
html += pagedata;

Anyone know what the correct syntax to accomplish this would be?

  • 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-13T11:27:25+00:00Added an answer on June 13, 2026 at 11:27 am

    I finally got the code to work. Here is the full code (not including jquery-ui related code). External pages need to be named the same as the list id.

    HTML

        <div id="example-2-3">
    
                    <div class="column first">
    
                        <ul class="sortable-list">
                            <li class="sortable-item" id="id1"></li>
                            <li class="sortable-item" id="id2"></li>
                            <li class="sortable-item" id="id3"></li>
                        </ul>
    
                    </div>
    
                    <div class="column">
    
                        <ul class="sortable-list">
                            <li class="sortable-item" id="id4"></li>
                        </ul>
    
                    </div>
    
                    <div class="column">
    
                        <ul class="sortable-list">
                            <li class="sortable-item" id="id5"></li>
                            <li class="sortable-item" id="id6"></li>
                        </ul>
    
                    </div>
    
        </div>
    

    Script

    $(document).ready(function(){
    
        window.onload = loadItemsFromCookie('cookie-2');
        // Get items
        function getItems(exampleNr)
        {
            var columns = [];
    
            $(exampleNr + ' ul.sortable-list').each(function(){
                columns.push($(this).sortable('toArray').join(','));                
            });
    
            return columns.join('|');
        }
    
        // Load items from cookie
        function loadItemsFromCookie(name)
        {
            if ( $.cookie(name) != null )
            {
                renderItems($.cookie(name));
            }
            else 
            {
                alert('No items saved in "' + name + '".');
            }   
        }
    
        // Render items
        function renderItems(items)
        {
            var html = '';
            var pagedata = '';
    
            var columns = items.split('|');
    
            for ( var c in columns )
            {
                html += '<div class="column';
    
                if ( c == 0 )
                {
                    html += ' first';
                }
    
                html += '"><ul class="sortable-list">';
    
                if ( columns[c] != '' )
                {
                    var items = columns[c].split(',');
    
                    for ( var i in items )
                    {
                        html += '<li class="sortable-item" id="' + items[i] + '">';
    
                        var pagedata = '';
                        var scriptUrl = items[i] + ".html"
                        $.ajax({
                            url: scriptUrl,
                            type: 'get',
                            dataType: 'html',
                            async: false,
                            success: function(data) {
                                result = data;
                                html += data;
                            } 
                        });
    
                        html += '</li>';
                    }
                }
    
                html += '</ul></div>';
            }
    
            $('#example-2-3').html(html);
        }
    
        $('#example-2-3 .sortable-list').sortable({
            connectWith: '#example-2-3 .sortable-list',
            update: function(){
                $.cookie('cookie-2', getItems('#example-2-3'));
            }
        });
    
    });
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please refer to http://jsfiddle.net/UEePE/1025/ for the x-axis, when I don't want to skip any
The Background (skip to the bottom if you want the question) Recently I upgraded
Please help me how can I skip these conditions? I am using factory pattern.
I am using JSF 2.0 and have defined property javax.faces.FACELETS_SKIP_COMMENTS to skip comments in
this is my first post so please show some understanding. I have some java
OK, what I'm trying to do here is to have jQuery UI update the
a have a small problem when i want to skip from the first view
Please note this question related to performance only. Lets skip design guidelines, philosophy, compatibility,
please have a look at the following code import java.util.ArrayList; import java.util.List; public class
Please see here , at the end of the post, the 70px author image

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.