1

I want to add a custom div at the end of jQuery-autocomplete list

I tried adding that custom div under ul.

autoCompleteDiv.data("ui-autocomplete")._renderMenu = function (ul: JQuery, items: any) {
                var that = this;
                let extraDivHtml: string = '';
                $.each(items, function (_key, value) {
                    if (value.IsExtraDivHtml=== false) {
                        that._renderItemData(ul, value);
                    } else {
                        extraDivHtml= value.ExtraDivHtml;
                    }
                });

                if (extraDivHtml.length > 0) {
                    $(extraDivHtml).appendTo(ul);
                }
            };

But it's not showing properly and throwing error in console.

Console Error

Can we do this using jQuery Autocomplete? Or any other JS, We can use this feature?

1 Answer 1

1

You can try adding a callback for the open event:

$("#yourAutocomplete").autocomplete({
    source: yourSource,
    'open': function(e, ui) {
        $(".ui-autocomplete").append(extraDivHtml);
}});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.