I have a form with over 100 list items that I must reorder on submit. The following code works to reorder my list without any apparent problems in Firefox; however, IE prompts with the message "A script on this page is causing Internet Explorer to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort the script?" If the user clicks 'No', the script will work as expected.
var listitems = $(form).find('li').get();
listitems.sort(function(a, b) {
var compA = $(a).attr('id');
var compB = $(b).attr('id');
return (compA - compB);
});
Any ideas on how to make this more efficient?
I didn't try it with 100 items but it totally worked with 2.
listitems.sort(function(a, b) {
return (a.id - b.id);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With