long script in IE

Asked

Viewed 38 times

0

A client reported that in his IE is presenting a message that the script was too long, causing a lock.

$(document).ready(function () {
    $('select').each(function () {
       $(this).select2({
           allowClear: true,
            dropdownAutoWidth: true
        });
    });
});

My code above, does anyone have any suggestions?

  • 1

    The problem is this $('select'). each(Function(), do you really need to scan all 'selects' from the page ? this code will go through ALL selects of the page which probably causes the slowdown

  • But it enters the select each only five times as they are 5 select even.

  • I did so, I think it can improve: $('select'). Select2({ allowClear: true, dropdownAutoWidth: true });

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.