Is there a way to make a sortable aware of new items, without
destroying and recreating the sortable ?
Thanks
Andrei a écrit :
> Is there a way to make a sortable aware of new items, without
> destroying and recreating the sortable ?
Not that I know of, and the source code, er... concurs :-)
Actually, manually going into the details of registering stuff with
sortable would:
- create a coupling to undocumented, mostly internal, workings. This
could very well mean code break down the road, as spinoffs code is a bit
volatile
- end up with such a minor improvement in performance, if any, that it
would prove pretty useless.
BESIDES, you DO need to unregister all internal droppables when you're
about to replace the list. It's a mandatory requirement when using
draggables/droppables: if you remove such elements from the DOM,
unregister them first. Sortable.destroy takes proper care of that for you.
--
Christophe Porteneuve a.k.a. TDD
"[They] did not know it was impossible, so they did it." --Mark Twain
Email: t...@tddsworld.com
That shouldn't be a problem as the javascripts are shipped with the
application, so I am in control of what libraries the user uses, and I
will thoroughly test new js libraries before using them in the
application.
About the performance:
I don't think it will be minor; creating a sortable with 80 items
already makes the browser hang for a while so anything that prevents
that from happening more than once is welcome (especially since my
lists may have hundreds of items).
Regards,
Andrei
The sortables represent a very, very generic and flexible way to
easily add "sortable" behaviour to a list of elements. It's not
optimized for performance with huge numbers of items, so you probably
need to investigate a solution that's more specifically optimized for
your needs.
For example, if the document isn't changing (like new nodes added or
positioning changes) while dragging and reodering occurs, you easily
improve performance by caching the positions of the sortable items in
your code (this will probably provide more than enough extra
responsiveness).
If someone is up to it, such a behaviour could probably made into
sortables/draggables with some kind of option.
Best,
Thomas