Comments (13)
Since you seem to have figured it out, would you mind putting in a pull request for the change needed to fix?
from nestedsortable.
I'm sorry, I tried to find where the real problem is but I failed. My OOP JS knowledge is very slight. All I can say is that on the _mouseStop event (line 377), the aswer to the if test on line 406 is always "false".
Indeed, the two following statements are always true:
1/ $(this.domPosition.parent).parent().attr("id") == this._uiHash().item.parent().parent().attr("id")
2/ $(this.domPosition.prev).next().index() == this._uiHash().item.index()
The ids and the indexes returned are always the one of the dragged element BEFORE it is moved.
from nestedsortable.
I'll take a look when I get a chance, or maybe someone can before I do - depends on my schedule.
Thanks for trying anyway!
from nestedsortable.
@twicejr mind taking a look?
from nestedsortable.
Thank you a lot.
There is no hurry for me since I've triggered the move is allowed (!=revert). The event is triggered to often (even when the item hasn't move), but it works anyway ;-)
One nice addition would be to pass as arguments of the relocate function the new and the old position of the item. For instance, my script is saving the new location in real time, and not only after clicking on a "save" button. I managed to do it by exporting the toArray output and comparing it with a saved version, but it could have been not much easier to do, especially since the previous and current index and parent id should be retrieved in the script just before triggering the relocate event (at least, once the bug will be fixed).
from nestedsortable.
@DrSchizo , I assume you did NOT forget the comma after the change function, as in your sample code?
Will look into it when I have time. I think whatever.parent().parent().attr("id") is not a very elegant solution anyway!
from nestedsortable.
No, I didn't. The code hasn't been written made by me. The mistake is in the file "jquery.mjs.nestedSortable.js". The two comparisons in the if test are always true and therefore the test always fails.
var pid = $(this.domPosition.parent).parent().attr("id");
var sort = this.domPosition.prev ? $(this.domPosition.prev).next().index() : 0;
if(!(pid == this._uiHash().item.parent().parent().attr("id") &&
sort == this._uiHash().item.index())) {
this._trigger("relocate", event, this._uiHash());
}
You can see the bug by adding this code below:
console.log('pid = '+pid+' and '+this._uiHash().item.parent().parent().attr("id"));
console.log('sort = '+sort+' and '+this._uiHash().item.index());
from nestedsortable.
I think we should solve this in a similar way I coded the disableParentChange functionality.
//pseudo code:
!(oldParent.is(newParent) && oldItem.index() == newItem.index())
from nestedsortable.
I ran into the same problem. Perhaps the proposal below will solve the problem.
(It does seem to work as expected in my tests)
It seems there's just a small flaw in the if... else... logic. (See below).
(Can you verify this solution?)
/*
// ORIGINAL CODE
if (!(pid == this._uiHash().item.parent().parent().attr("id") &&
sort == this._uiHash().item.index())) {
this._trigger("relocate", event, this._uiHash());
}
*/
// POSSIBLE SOLUTION
var isRelocated = false;
if (pid !== this._uiHash().item.parent().parent().attr("id")) {
isRelocated = true;
} else if( sort !== this._uiHash().item.index() ) {
isRelocated = true;
}
if (isRelocated) {
this._trigger("relocate", event, this._uiHash());
}
from nestedsortable.
See:
https://github.com/tfddev/nestedSortable
from nestedsortable.
If you solved it, please put in a pull request.
On Sat, Sep 20, 2014 at 9:19 PM, TFD - DevDept [email protected]
wrote:
See:
https://github.com/tfddev/nestedSortable—
Reply to this email directly or view it on GitHub
#4 (comment)
.
from nestedsortable.
I'm afraid tfddev's proposal does not solve the problem. The underlying problem still is as DrSchizo mentioned:
"The ids and the indexes returned are always the one of the dragged element BEFORE it is moved."
from nestedsortable.
It is fixed and tested in the latest version.
from nestedsortable.
Related Issues (20)
- Load from AJAX data
- Allow Drag-Drop from one nestedSortable tree to another HOT 2
- Is there any way to make it work on mobile devices? HOT 1
- Depth count - difference between current code and demo
- Store nestedSortable into the Database HOT 2
- Does not working if inserting into blank branch
- Prefix for item is forced since 2.0
- Depth and Index
- iPad moving
- Has anyone gotten this to work on mobile devices (touch support)? HOT 1
- Maintain nesting level. Prevent item being dropped in parent but allow another container of same level
- Where is the Placeholder move along X-axis defined?
- How 3rd level sub menu in menu.liquid
- Create a dynamic nested sortable accordion
- Allow parent change on items that are not parents?
- Sorting Breaks with jQuery UI 1.13+ HOT 4
- Scrolling issue using laptop touch page
- Release of new version?
- "jquery-ui/ui/sortable" is a reference to jquery-ui version 11 only
- Not working with jquery-ui v. 1.13.2
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 nestedsortable.