Commits

Scott Nixon committed efc4513 Draft

Added autocomplete to the recipe name search. Upgrade Bootstrap JS only to 2.0.4.

  • Participants
  • Parent commits cf600f3

Comments (0)

Files changed (3)

File article/templates/recipe_list.html

              <div class="search-box">
                 <h2>Search by Recipe Name</h2>
                 <form action="/recipes/" method="get">
-                  <input name="qname" type="text" id="recipe" value="{{ request.GET.qname }}" required />
+                  <input name="qname" type="text" id="recipe" value="{{ request.GET.qname }}" data-provide="typeahead" data-minLength='2' data-source='[{% for i in autocomplete %}"{{ i.recipe_name }}"{% if not forloop.last %},{% endif %}{% endfor %}]' required data-items="4" autocomplete="off"/>
                   <input type="submit" value="Find recipes" class="button-orange-big-round" />
                 </form>
              </div><!-- / search-box -->
   </div><!-- / content -->  
 
 {% endblock %}
+{% block extra_body %}
+{% endblock %}
+
+{% block onready %}
+$("#recipe").typeahead();
+{% endblock %}

File article/templates/theme_base.html

         
     
     {% block extra_body_base %}
-    <script src="//css.happyherbivore.com/bootstrap.min.js"></script>
+    <script src="//css.happyherbivore.com/bootstrap204/js/bootstrap.min.js"></script>
         {% block extra_body %}{% endblock %}
+        $(document).ready(function(){
+        {% block onready %}{% endblock %}
+        });
     {% endblock %}
 
     {% gblock 13 for "gblocks.Text" into "viglink" %}

File article/views.py

         return queryparams
 
     current_site = Site.objects.get_current()
+    autocomplete = Recipe.active.filter(sites=current_site.id).order_by('recipe_name')
     sub_featured = Recipe.active.filter(recipephotos__type=3, 
                                         featured_items=3)[:7]