简体   繁体   中英

Jquery Autocomplete take long time

I am making an example with nwjs and into that I am using angular and a Jquery plugin to make a field autocompleted, I am using the plugin named " https://api.jqueryui.com/autocomplete ".

The code

$("#descriptionId").autocomplete({
    source: $scope.availableDescriptions,
    minLength: 1,
    delay: 0,
    focus: function(event, ui) {            
        event.preventDefault();
        $('#descriptionId').val(ui.item.label);
        //CODE
    },
    select: function(event, ui) {
        event.preventDefault();
        $('#descriptionId').val(ui.item.label);            
    }
});

Some description of the code;

The Source is a list of more that 700 records that I loaded from the database.

The Problem

if I play into the field, adding and deleting the text after some time the field starts to be very slow each time. I was reading the documentation of the plugin but I cann't see anything wrong. The weird is that if I refresh the controller the field start working fine again.

any help of people with more experience in Javascript and jquery could be amazing.

Not sure about your scenario as there are several factors affecting UI like memory leaks or rendering issues, but I would recommend to put some delay over here like delay:500 (500ms). It will add a delay of 500ms to server request rather than sending just after typing.

经过一番调查后,我发现在stackoverflow中报告了相同的问题,答案在这里

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM