Mark Lavin avatar Mark Lavin committed a038570

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

Comments (0)

Files changed (3)

 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
 --------------------------------------

docs/advanced.rst

 
 .. _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
             });
         </script>
 
+
+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.

example/templates/admin/base_site.html

 {% 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>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.