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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:47:54+00:00 2026-05-27T23:47:54+00:00

I have a page with two lists. The list on the left has some

  • 0

I have a page with two lists. The list on the left has some “optional” items. The list on the right is the main list that will be pre-populated with required items.

The user should be able to drag optional items back and forth between the two lists as well as to sort them in either list.

The users should be able to sort the main list items (both required and optional), but should not be able to drag a required item to the optional list.

Does this make sense?
What’s the best way to achieve this?

I’ve tried different ways of doing this with the jquery sortable, but can’t seem to get it right.
Any help is much appreciated.

An example list:

<div id="Selector">
<ul id="OptionalFields" class='droptrue'>
    <li class="ui-state-highlight, optional">Optional 1</li>
    <li class="ui-state-highlight, optional">Optional 2</li>
    <li class="ui-state-highlight, optional">Optional 3</li>
    <li class="ui-state-highlight, optional">Optional 4</li>
</ul>
<ul id="FileFields" class='droptrue'>
    <li class="ui-state-default, required">Required 1</li>
    <li class="ui-state-default, required">Required 2</li>
    <li class="ui-state-default, required">Required 3</li>
</ul>

Currently, my script looks like this:

$(function () {
    $("#OptionalFields").sortable({
        containment: '#Selector',
        tolerance: 'pointer',
        connectWith: '#FileFields',
        cursor: 'pointer',
        revert: 'true',
        opacity: 0.6,
        receive: function () {
            if ($(this).hasClass("required")){ return false};
        }

    });

    $("#FileFields").sortable({
        containment: '#Selector',
        tolerance: 'pointer',
        connectWith: '#OptionalFields',
        cursor: 'pointer',
        revert: 'true',
        opacity: 0.6,
        update: function () {
            //alert('sorted');
        }
    });
});

Thanks,
Tony

edited a type/syntax error.

  • 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-27T23:47:55+00:00Added an answer on May 27, 2026 at 11:47 pm

    Ok, found a solution:

     $(function () {
        $("#OptionalFields").sortable({
            containment: '#Selector',
            tolerance: 'pointer',
            connectWith: '#FileFields',
            cursor: 'pointer',
            revert: 'true',
            opacity: 0.6,
            receive: function (event, ui) {
                if (ui.item.hasClass('required')) {
                    $(ui.sender).sortable('cancel'); 
                };
            }
    
        });
    
        $("#FileFields").sortable({
            containment: '#Selector',
            tolerance: 'pointer',
            connectWith: '#OptionalFields',
            cursor: 'pointer',
            revert: 'true',
            opacity: 0.6,
            update: function () {
                //alert('sorted');
            }
        });
    

    Notice the changes to the receive event and the change to how I cancel.
    This will cancel the drop.
    Now to make it pretty. =)

    I also fixed the classes specified for the list items by removing the commas.

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

Sidebar

Related Questions

We have a page that ordinarily has two elements arranged side-by-side. Despite exploring a
I have two sortable lists that are connected. One is simply on the page,
I have a page here that shows two classgroups - groups/lists of students -
I have a user control in a master page with two drop down lists.
I have a page with two ContentPlaceHolders. One has a DropDown and another UpdatePanel
I have a page with two tabs that I want to be able to
I have an aspx page with two buttons, one of the buttons has an
I have a page that displays a table in two different modes. In each
I have some page elements which are meant to appear in a two column
I have page of two columns with left bar. On the left side I

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.