How to get html elements/templates instead of string in jQuery's autocomplete? I want the movie element to work coming from `include` tag.

scripts:-

$(function(){
        var availableMovieTitles = [
            {% for movie in movies_on_hold %}
                "{{movie.title}}",
            {% endfor %}
        ];
        
        let availableMovies = [
        {% for movie in movies_on_hold %}
            `{% include 'movies/includes/movie.html' %}`,
        {% endfor %}
        ];

        $( "#search" ).autocomplete({
        source: availableMovies
        });
      });

This is what I’m getting:-

I want this element to be in the autocomplete search results:-

Try from both of this if any of it works

source: availableMovies|safe

OR

{% include 'movies/includes/movie.html' %}|safe

Both didn’t work. But i found the solution.

( "#search" ).autocomplete({
        source: availableMovies,
        minLength: 2,
        select: function(event, ui) {
            event.preventDefault();
        },
        })
        .data("autocomplete")._renderItem = function (ul, item) {
            return $("<li></li>")
                .data("item.autocomplete", item)
                .append("<a>" + item.label + "</a>")
                .appendTo(ul);
        };

is this really django-related?