Eldamir
Eldamir

Reputation: 10062

Using JQuery autocomplete widget with django

I realize there are a lot of posts regarding this issue, but nothing has helped me so far.

I am putting together a Django website, and i need a form with a searchable field, that is, a standard text input, that uses the given text to filter a drop-down list of options.

This feature is exactly like what is presented at the JQuery website: http://jqueryui.com/demos/autocomplete/

I just cannot seem to make it work. Below is my code:

<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>

<script type="text/javascript">
    $(function() {
        var availableTags = [

            { label: "Mosek ApS, Ruben Nielsen", value: "8" }

        ];
        $( "#tags" ).autocomplete({
            source: availableTags
         });
   });
</script>
</head>
<body>
    <input id="tags">
</body>

to my eye, this is completely like the example code at the JQuery site referenced above. The input box shows, but no drop-down menu appears, when i start typing the text of the label (label: "Mosek ApS, Ruben Nielsen")...

Any help..?!

Upvotes: 2

Views: 856

Answers (2)

Timmy O&#39;Mahony
Timmy O&#39;Mahony

Reputation: 53990

You need to include jQuery UI (which is a separate library to plain jQuery) javascript and CSS:

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/base/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.22/jquery-ui.min.js"></script>

Upvotes: 1

Lie Ryan
Lie Ryan

Reputation: 64865

jQuery Autocomplete is part of jQuery UI library, so you need to include it with the page as well as the core jQuery library.

Upvotes: 0

Related Questions