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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:46:28+00:00 2026-05-29T22:46:28+00:00

i have three list that all of them are connected with jquery-ui sortable, first

  • 0

i have three list that all of them are connected with jquery-ui sortable, first list is Backlog works, second is in-Progress and last is finished.

i want move an item from first list to second and from second to third, if an item moved from first list to third list, list don’t accept element.

now all is done, but i dont know how prevent items begin moved on other connected list for example if has “a” (or …) classes?

$(function(){
$(".tasks").sortable({
    connectWith : ".tasks",
    handle : "h2",
    items : ".task",
    opaciry : 0.6,
    revert : true,
    placeholder : "ui-state-highlight",
    forcePlaceholderSize : true,
    remove : function(e,obj){
        $(".tasks").each(function(){
            if($(this).children(".task").length == 0){
                $(this).addClass("empty");
            } else if($(this).hasClass("empty")) {
                $(this).removeClass("empty");
            }
        });
    },
    out : function(e,obj){
        $(".col").removeClass("red green");
        $(".tasks").sortable("enable");
    }
});
$("#p .tasks").sortable({
    receive : function(e,obj){
        obj.item.removeClass("tb").addClass("td");
    },
    over : function(e,obj){
        if(obj.item.hasClass("tb")) {
            $("#p").addClass("green");
        } else {
            $("#p").addClass("red");
            $("#p .tasks").sortable("disable");
            return false;
        }
    }
});

});

  • 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-29T22:46:30+00:00Added an answer on May 29, 2026 at 10:46 pm

    One way to do it would be to use the ‘receive’ callback in conjunction with the ‘cancel’ method to validate any moves. jsFiddle

    $(".tasks").sortable({
        connectWith: ".tasks",
        receive: function (event, ui) {
            var validMove = function (a, b) {
                    var changeMatrix = [
                        [true, true, false],
                        [true, true, true],
                        [false, true, true]
                    ];
                    return changeMatrix[a][b];
                },
                $lists, endList, startIndex, endIndex;
            $lists = $(".tasks");
            endList = $(ui.item).closest('.ui-sortable').get(0);
    
            startIndex = $lists.index(ui.sender);
            endIndex = $lists.index(endList);
    
            if (!validMove(startIndex, endIndex)) {
                $(ui.sender).sortable('cancel');
            }
        }
    }).disableSelection();
    

    Here I have made a matrix of acceptable moves and a function that validates based on the index of the source and destination lists. The source list is easy to get thanks to the ui object provided as a parameter by .sortable(), the destination list requires some quick traversal.

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

Sidebar

Related Questions

I have three lists that I want to convert into one list. When I
I have a list of items heading that are all in INTEGER (yes the
I have a list of strings that are all early modern English words ending
I have a binary tree in unordered list that looks like this: <ul> <li>1
I have a site where there will be a list of offers that the
On this page there is a list of footer links that have a little
I have a search page that if there is results in the list it
I have a page in Sitecore that displays the list of clients. There's a
I have a class Player that contains a list of Accessory objects. There are
I have a list of MyObjects which I need to divide into three groups:

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.