-
Notifications
You must be signed in to change notification settings - Fork 440
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
Removing elements from DOM doesn't destroy sortable #106
Comments
Why are you not able to call |
I can, but then a simple task of binding a sortable to some DOM element will consist of having to make sure that every case which leads to removing that element from DOM is preceded by calling I don't know where you store In any case, current behavior is very unintuitive, and at the very least, should be documented. |
Are you using a library like Ember, Angular OR React? Sounds like a spaghetti problem. Try to use a library to help you manage your objects. |
I have precisely the same problem and before you ask, it is not spaghetti code. The first time the backbone view renders everything works as planned. However subsequent renders are problematic because the original grouped lists have not properly been removed from memory. I have found a workaround which is to change the name of the group each time the view is rendered, however this does not solve the underlining problem which @dwelle has highlighted, as well as leaving concerns of a possible memory leak. That aside, I have to say that this is definitely the best sortable plugin I have used. Thank you. |
I would like to nail this once and for all. Can you tell me what version you are using. If you can provide a minimal version on jsbin or similar, fixing it will be On Tue, Jul 29, 2014 at 3:31 PM, Hoolagon [email protected] wrote:
|
There's a JSFiddle in my original post. |
Same issue: jquery-sortable.js v0.9.12 with jquery 2.1.1 and bootstrap 3.2.0. I even call 'destroy' but global state is persisted somewhere and "old" callbacks (e.g. onDrop) are called. I fixed the issue by adding the timestamp to the group name which is a clear indicator of some kind of state leftover. |
It's jquery-sortable.js v0.9.12 with backbone 0.9.2. However I don't think the frame work has anything to so with it. Dwelle's original JSFiddle describes the problem sufficiently. |
My solution to that problem as a library user was to:
It helped - now i can reload parts of html using ajax and reinitialize sortable with new data. |
here is working updated fiddle http://jsfiddle.net/SmRM2/8/ $("ul").sortable({ to $("ul").sortable({ for different group. |
@mujeebasif This is a funny solution to the problem, but fairly enough - it helped me to workaround the issue. |
When a sortable is bound to group which is later removed from DOM (
$.remove()
or simply replaced), sortable is still bound to it if it's not manually destroyed before removing the elements from DOM. This messes up sortable when it's later bound to that group again.Related to #99, and #94
If nothing else, it would be great to be able to
destroy
all sortables (or particular group). Callingsortable('destroy')
on those non-existent DOM elements is futile.JSFiddle here
The text was updated successfully, but these errors were encountered: