1. Mark Lavin
  2. django-selectable


Mark Lavin  committed a038570

Adding documentation on using django-selectable with dynamically added forms. Fixes #31.

  • Participants
  • Parent commits 6330cef
  • Branches default

Comments (0)

Files changed (3)

File docs/admin.rst

View file
  • Ignore whitespace
 on `overriding the default widgets <http://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#overriding-the-default-field-types-or-widgets>`_. As you will see integrating Django-Selectables in the admin
 is the same as working with regular forms.
+.. _admin-jquery-include:
 Including jQuery & jQuery UI

File docs/advanced.rst

View file
  • Ignore whitespace
 .. _chain-select-example:
-Chained Selection Example
+Chained Selection
 It's a fairly common pattern to have two or more inputs depend one another such City/State/Zip.
 detail you should refer to the `jQuery UI docs on these events <http://jqueryui.com/demos/autocomplete/#events>`_.
-Submit On Selection Example
+Submit On Selection
 You might want to help your users by submitting the form once they have selected a valid
+Dynamically Added Forms
+django-selectable can work with dynamically added forms such as inlines in the admin.
+To make django-selectable work in the admin there is nothing more to do than include
+the necessary static media as described in the 
+:ref:`Admin Integration <admin-jquery-include>` section.
+If you are making use of the popular `django-dynamic-formset <http://code.google.com/p/django-dynamic-formset/>`_
+then you can make django-selectable work by passing ``bindSelectables`` to the 
+`added <http://code.google.com/p/django-dynamic-formset/source/browse/trunk/docs/usage.txt#259>`_ option:
+    .. code-block:: html
+        <script type="text/javascript">
+            $(document).ready(function() {
+                $('#my-formset').formset({
+               		added: bindSelectables	
+                });
+            });
+        </script>
+Currently you must include the django-selectable javascript below this formset initialization
+code for this to work. See django-selectable `issue #31 <https://bitbucket.org/mlavin/django-selectable/issue/31/>`_
+for some additional detail on this problem.

File example/templates/admin/base_site.html

View file
  • Ignore whitespace
 {% extends "admin/base.html" %}
 {% block title %}{{ title }} | Django-Selectable Example Site{% endblock title %}
 {% block extrahead %}
-<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen">
-<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
-<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
+<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/ui-lightness/jquery-ui.css" type="text/css" />
+<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
+<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
 {% endblock %}
 {% block branding %}
 <h1 id="site-name">Django-Selectable Administration</h1>