Sortable on dynamically created elements
Hi all,
Not directly an issue, but I'm trying to get sortable working on divs I dynamically create. Any idea how to solve this? So far it doesn't seem to work.
I am not the author of this fiddle, but it does what you are looking for http://jsfiddle.net/06y0w14b/
EDIT: That's actually a complicated example with nested sortables. If you are looking for something a lot more simple, try this http://jsfiddle.net/tn0nr3b5/19/
is there any way to initialize Sortable instance on element which is not present in DOM yet but will add dynamically later
@azinkey If it works on an element that is not in the DOM then yes, but if not there is no special way to make it work
Thank you @activestylus! I'm coming from 2020 and you saved my day.
I am not the author of this fiddle, but it does what you are looking for http://jsfiddle.net/06y0w14b/
EDIT: That's actually a complicated example with nested sortables. If you are looking for something a lot more simple, try this http://jsfiddle.net/tn0nr3b5/19/
I think what OP is referring to is going complete commando on the DOM. No DOM at all. He doesn't want to add dynamic elements to an already existing list, but want to create a sortable list that does not exist at all. I'm wanting to do the same thing. Creating the list dynamically with document.createElement() for instance. Like OP me too I've tried many many different ways to do this and the sortable must exist in the DOM if we want this to work.
How did you solve this 😅 @Evin89