Comments (2)
This should be possible. But with the current implementation, the drop has already happened at the moment you can check it with onDrop. So there might be a flicker if you remove the item again, after it has been dropped.
This would be a working example:
var backupItem
$("ul").sortable({
group: 'limited root',
exclude: ".hidden",
onDragStart: function (item, container, _super) {
// Duplicate item
backupItem = item.clone().insertAfter(item).addClass(".hidden")
_super(item)
},
onDrop: function (item, container, _super) {
if(itemInRightPlace(item, container)){
backupItem.remove()
_super(item)
} else {
item.remove()
backupItem.removeClass(".hidden")
}
}
})
But this looks too much like a hack. I might add something more convenient, so please tell me:
Would it be best, if the dragged items would register (aka the red arrow showing) only inside the root ul?
from jquery-sortable.
Hi There I am having the same type of issue where onDrop if values are met them the drop is rejected but cannot get the ol to revert back to its original position i have tried the above code but think the issue is that it is already inside of a sortable call. and help would be great.
`$("ol.left").sortable({
group: 'nested',
onDrop: function (event, ui){
var $this = $('.active');
var li = $this.parents('li');
var ol = $this.parents('ol').parents('ol');
var div = $this.closest('div');
li.removeClass("dragged");
li.removeAttr('style');
if (($(div).hasClass('left')) && ($(ol).hasClass('left'))) {
alert("test"); //code to revert goes here
} else {
update_fs();
}
}
});`
from jquery-sortable.
Related Issues (20)
- Column dragging with rowspan issue
- publish latest changes to npm HOT 1
- we can not use this other tag nested level
- Does not work with column-fill / feature request
- not working on mobile phone HOT 2
- After around ~30 drag&drop moves IE becomes very slow HOT 1
- MIT license?
- I can't sort items out of group
- reattach event handler after a jquery .html()
- Update required for jQuery 3.x - jQuery.fn.offset() requires an element connected to a document
- Unable to resort after using destroy
- Revert/undo a drop HOT 1
- Sortable handle, drag from the right, not the left
- Serialize option documentation is incomplete
- .sortable('toArray', {attribute: 'data-id')) returns a list of jQuery objects
- How to prevent child node to dragged in another parent node ... How to save Data to mysql and PHP HOT 2
- No longer works once upgrading jquery to 3.3.1
- what are the js/html/css for the first example?
- Example styling HOT 1
- Compatibility with Jquery UI sortable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-sortable.