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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:39:08+00:00 2026-06-03T15:39:08+00:00

How can I define what items to accept in a sortable? Like, say I

  • 0

How can I define what items to accept in a sortable?

Like, say I have the following pseudo markup:

<ul id="draggable">
   <li>Item 1</li>
   <li>Item 2</li>
   <li class="nodrag">Item 3</li>
   <li>Item 4</li>
</ul>

<ul id="sortable">

</ul>

I use the connectToSortable option in the Draggable to connect it to the sortable.

Since I have sortables within sortables (INCEPTION!! 😉 ) I want to be able to decide if a draggable is allowed to be dropped on a specific sortable.

How can I do this? I currently use the sortable stop event for manipulating the dropped object – I tried removing the object if it contains the nodrag class, but the “snap” effect is still shown (the effect where the draggable slowly moves into place in the sortable)

Is there any way I can do this?

  • 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-03T15:39:10+00:00Added an answer on June 3, 2026 at 3:39 pm

    I had a similar problem with a drag-and-drop app I was writing. The problem I had was that I had, say, 3 sortable lists like this:

    <ul class="apple">  <!--  accepts apples -->
    </ul>
    
    <ul class="apple orange">  <!--  accepts apples and oranges -->
    </ul>
    
    <ul class="orange banana">  <!--  accepts oranges and bananas -->
    </ul>
    

    Then I had another master list with apples, oranges and bananas that could be dragged into these lists. THe problem was obviously to restrict the draggables so that they can’t be dropped into incompatible lists.

    What I had to do was use the connectToSortable option on the draggables to specify which lists they could be dropped into. So I might define my draggables like so:

    <li class="drag-apple">...</li>
    <li class="drag-orange">...</li>
    <li class="drag-banana">...</li>
    
    $(li.drag-apple).draggable({ connectToSortable: '.apple', ... });
    $(li.drag-orange).draggable({ connectToSortable: '.orange', ... });
    $(li.drag-banana).draggable({ connectToSortable: '.banana', ... });
    

    With this in place, the draggables will only target the appropriate lists.

    In your case, I’m not sure if the nested sortables creates additional complexity. However, there is a nested sortables plugin that you might want to look at (nested Sortable). Hopefully similar techniques will work there.

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

Sidebar

Related Questions

I have defined the following: public ICollection<Item> Items { get; set; } When I
I can define default value in domain by this way : class ProcessingPriority {
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
How can i define each menu item in different line? Right now if I'm
I have a set of classes something like this: abstract class CollectionAbs implements Iterator
I often have a class defined and I also define another class that is
I'd like to define a class which is derived from System.Data.DataTable. This class has
I am trying to define a variable in a class that then can be
In CDI you can define an object that will give you items of a
How can I get the number of items defined in an enum?

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.