Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

Support for drop rejects with multiple rule-action sets #85

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

bperel
Copy link

@bperel bperel commented Oct 4, 2013

No description provided.

@schneikai
Copy link

Hey guys. How is this supposed to work actually? Is there an example how to use the reject option? Thanks!

@bperel
Copy link
Author

bperel commented Dec 18, 2013

Hi @schneikai, the use of the reject option is quite simple but, indeed, not documented, here's an example :

$('#nestable').nestable({
      reject: [{
        rule: function() { // The this object refers to dragRootEl i.e. the dragged element. The drag action is cancelled if this function returns true
          return $(this).find('>ol>input input').length > 0; // The rule here is that it is forbidden to have nested inputs in the hierarchy
        },
        action: function(nestable) { // This optional function defines what to do when such a rule applies. The this object still refers to the dragged element, and nestable is, well, the nestable root element
          alert('You can\'t do that !');
        }
      },
      { /* You can add another rule (and possibly an associated action) here */}
      ]
});

@schneikai
Copy link

Nice! Thank you!

@sebVier
Copy link

sebVier commented Dec 13, 2016

Hi @bperel , i know this is an old branch but fit's my current project quite well. Do you know if it's also possible to reject something based on the destination it's moved to?
For example i want to prevent people dropping items in the root of my tree but all other 'levels' are OK.
1-2
--2-3
--2-3
--2-3-4
In the above example lvl1 would be root, so offlimit's. But all others are fine so something from lvl4 could be dropped in lvl2 etc. etc.
having a hard time with this, hope you could share some insights :).
Thanks in advance!

@bperel
Copy link
Author

bperel commented Dec 14, 2016

@sebVier I'll check this in the next days

@sebVier
Copy link

sebVier commented Dec 14, 2016

Awesome thanks a lot!

@bperel
Copy link
Author

bperel commented Dec 17, 2016

@sebVier I had a look at this. You may have been confused by the inaccurate comments that I put on my code. I fixed that and updated from upstream into https://github.com/bperel/Nestable. Demo is on http://bperel.github.com/Nestable/

@sebVier
Copy link

sebVier commented Dec 18, 2016

@bperel Thank you so much! work's great now!

@jerviscui
Copy link

@bperel so good.
I have implemented a method like reject drop,
after that I see your fork. 😄 😄 😄

@bilalyilmax
Copy link

@bperel Thanks you for this solution. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants