-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behavior on third level nested tables #91
Comments
OK, so I found a bit of a nightmarish way around this. The problem is that, when you move to a second level item to a different first level item, a new container is created, but the old ones weren't deleted. There was a really a subset of three things to account for, when moving second level items - is the second level item being moved "up" in the first level array (needed to compare jQuery attribute's stored item with the newValue), moved "down" in the first level array (needed to check if the jquery attribute was undefined) and make sure the order works (by splicing the element into the correct part of the array). In the current solution, you have to specify the third level object yourself (in the line right below where this is noted in a comment. My link method code ended up like this: function register (angular) {
}]; |
We're seeing the same issue getting dragula angular to work with nested items, what's working for us is to amend drake.containers and drake.models when the DOM element is destroyed (which happens when it is dragged out of it's original position). Adding this to the link function seems to do the trick.
|
The above solutions are interesting dimension to think about. I am facing similar issue but the folder bag name is same for nested containers also. When I drop nested container to top container, I am getting the error same as above. It is because the index of the containers and models are not tied to similar index. |
I am using angular JS 1.5, if that matters (however this particular page is all written in a single component). Everything seems to be working correctly until a third level nested bag is required. Essentially there are three bags and three level objects (the actual names are different):
+
first-bag item in vm.items
second-bag subItem in item.subItems
third-bag subSubItem in subItem.subSubItems
IF, very specifically, you drag a second level item (subItem) to another second-bag and then drag a third level item (subSubItem), that is inside this very same second level item, to another third-bag, it seems like the drake.containers array does not update correctly (excess containers are not removed or they are unnecessarily created). When dragging and dropping this third level-item, an error at service.js 50th line (also contained in angular-dragula.js 1072nd line) is triggered -
Cannot read property '0' of undefined
at applyDrop (service.js:50)
This happens as a result of the sourceModel being undefined at line 44, which, in turn, happens, because there is one more container than there are models. For an example, if there are two subItems and two subSubItems throughout the whole model, at line 44 (or 1066 in angular-dragula.js) the source variable will match the third container (the number of containers increases the more you drag the second level item between bags), produces the index of 2 (or whatever is the last container), which is not a part of the models array. This results in an undefined SourceModel and in the drag and drop not working. The situation can be viewed in the following images.
Unfortunately I can't quite upload my source code, but, if there are any ideas as to how this could be fixed or circumvented, please tell me. Thank you for reading and any responses.
The text was updated successfully, but these errors were encountered: