I am creating a drag and drop calendar and found that jQuery UI sortable offers the best live performance for what I'm trying to do.
However, using sorting for several months (from 60 to 180 days at a time, sometimes more) leads to a noticeable lag in page loading, since my script uses all of these sortable instances. It works fine after loading, but I would prefer not to have an initial lag. In some cases, the browser even tries to kill the script.
I tried to make the first day of sorting the calendar, and then using jQuery.clone () copy all the other days, but unfortunately jQuery.clone () does not copy .sortable events. Other events (such as a click, double click, etc.) are copied in order, but not sorted. While doing some research on the Internet, all I could find was the statement that jQuery "does not support plugin cloning."
Is there a better way to do this? I looked through stackoverflow, jQuery UI forums, and Google in general and found nothing.
Thanks in advance, jamon
EDIT: Here is the code. Nothing special.
function sortableStop(event, ui) { // Saves to the DB here. Code removed - not relevant } $(".milestone-day").bind("dblclick", function(ev) { // Allows adding milestones. Code removed - not relevant }).sortable({ handle: '.handle', connectWith: '.milestone-day', items: '.milestone', stop: sortableStop });
The markup is as follows:
<table> <tbody> <tr> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> </tr> <tr> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> <td><ul class="milestone-day"></ul></td> </tr> ... </tbody> </table>
Milestones are li elements uploaded on their correct weekend through ajax.
EDIT 2: Working demo published:
http://www.clearsightstudio.com/demos/calendar-load/ Affairs>
EDIT 3: The demo has disappeared. Unfortunately.
Please note that there is a delay when opening the page. There is much more going on than on this demo in my real application, so the lag is even more noticeable.