{% extends "base.html" %} {% block title %} just_javascript demo - {{ block.super }} {% endblock %} {% block extrahead %} {% include 'autocomplete_light/static.html' %} {% endblock %} {% block branding %} go back

just_javascript demo

{% endblock %} {% block content %}

This simple demo shows, how to create a fully working autocomplete-light widget just by JavaScript, at client side.

Please note, that at server-side, this demo uses objects called Bar from Admin Test Autocomplete demo, running in the Django Admin interface of this humble application. So, if the pop-down list of the autocomplete objects is empty, please click here to add more objects to the database.

The idea is described in the documentation.

Here's our input text field, created in the simplest possible way: As you can see, it is really simple. It allows the user to choose values from a dropdown box. But what if the user types something, that is not in the autocomplete field? This value will be sent to server. Is it what you really want? Maybe not. Anyway, having such simple field should give you a possibility to extend it whenever you need it.

There is another option: to create widget using a pre-defined template. Such widget must have an expected structure in HTML. You can see such widget here: Default option   Click the grey "X" button to remove it's default value and to reveal the text input field. As you can see, this widget takes care of many problems, at the cost of more complicated structure (see source).

{% endblock %}