Slow performance when initializing AutoComplete
Trying to apply the AutoComplete bundled with UI 1.8.2 to 280+ input fields on a page. I noticed that the initial rendering of the page is somewhat slow and upon investigation I see that the initialization of the plug-in is the culprit.
The following code takes over 7 seconds to execute in FF 3.6.3 with IE7 taking even longer.
- console.time('autocomplete');
- $("input[id$='Project']").autocomplete({
- minLength: 3,
- source: function (request, response) {
- $.ajax({
- url: '<%= Url.Action("FetchProjects", "Projects") %>',
- dataType: 'json',
- data: {
- criteria: request.term,
- limit: 15
- },
- success: function (data) {
- response($.map(data, function (item) {
- var label = item.Id + ' (' + item.Name + ')';
- return {
- label: label.replace(new RegExp('(' + $(this).val() + ')', 'gi'), '<strong>$1</strong>'),
- value: item.Id
- }
- }))
- }
- });
- },
- select: function (e, ui) {
- $(this).val(ui.item.Id);
- }
- });
- console.timeEnd('autocomplete');
Anybody have any idea what the AutoComplete is doing to take so long? It's not like it is loading data during its initialization routine.
Thanks.
- Jason