Skip to content

Disable sorting below a certain item #1019

Closed

Description

@nickkuijpers

Hello!

I am creating a menu with children sort object in Vue.

All is working well, but is it possible to disable to possibility to not be able to drop it below a certain item but above it can?

So like this:

Item1
Item2

  • Subitem1
  • Subitem2
    Item3
    Disabledfield ( used so we can drop after it when it ends with children)

I want to be able to drop it above Disabledfield but not below.

Is this possible?

Activity

  1. hundekoerper commented on Jan 12, 2017

    @hundekoerper

    maybe this issue can help you #347

  2. ulken commented on Jan 14, 2017

    @ulken

    Sounds like a combination of filter and onMove is what you are after. See #1021 for an example.

  3. nickkuijpers commented on Jan 16, 2017

    @nickkuijpers
    Author

    This is exactly what i need. Thanks so much!!!

  4. func-dave commented on Mar 28, 2020

    @func-dave

    Sorry for necro-post, it helped me to use the following here in 2020.

    new Sortable(stimuliCards, {
        draggable: '.stimuli-card:not(.stimuli-card-start)',
        filter: '.no-drag',
        onMove: event => {
            return !event.related.classList.contains('.no-drag');
       }
    });
    
  5. Adeel992 commented on Feb 22, 2022

    @Adeel992

    Is there any way to make some items disable on a list?

  6. ulken commented on Feb 22, 2022

    @ulken

    Is there any way to make some items disable on a list?

    If I understand you correctly, then sure. The filter option is what you're after. From the docs:

    filter: ".ignore-elements",  // Selectors that do not lead to dragging (String or Function)

    Depending on your setup, you could also do the invert and specify which items should be draggable. Again, from the docs:

    draggable: ".item",  // Specifies which items inside the element should be draggable

    You find example usages in previous comments and linked issues in this thread or the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions