Skip to content
Browse files

Adding beginning of stupid autocomplete

  • Loading branch information...
1 parent 403c491 commit 670d5a14ae1a92269cddf75b01c1aba17efe13b5 @ikai committed Apr 11, 2012
Showing with 25 additions and 0 deletions.
  1. +10 −0 pick/static/js/pickaplace.js
  2. +6 −0 pick/templates/index.html
  3. +8 −0 pick/views.py
  4. +1 −0 urls.py
View
10 pick/static/js/pickaplace.js
@@ -11,6 +11,16 @@ PAP.onReady = function() {
source: availableCities
});
+ $( "#venueSelect" ).autocomplete({
+ source: "/venue_search",
+ minLength: 2,
+ select: function( event, ui ) {
+ console.log( ui.item ?
+ "Selected: " + ui.item.value + " aka " + ui.item.id :
+ "Nothing selected, input was " + this.value );
+ }
+ });
+
// check for Geolocation support
if (navigator.geolocation) {
console.log('Geolocation is supported!');
View
6 pick/templates/index.html
@@ -50,6 +50,12 @@
<p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>
</div>
+ <div class="ui-widget">
+ <label for="venueSelect">Type the name of a restaurant, bar or cafe: </label>
+ <input id="venueSelect" />
+ </div>
+
+
<!-- Example row of columns -->
<div class="row">
<div class="span4">
View
8 pick/views.py
@@ -1,5 +1,13 @@
+import json
+
+from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect
def home(request):
return render_to_response("index.html")
+def venue_search(request):
+ response = [
+ { "label" : "A Bar", "value" : "a bar" }
+ ]
+ return HttpResponse(json.dumps(response))
View
1 urls.py
@@ -7,6 +7,7 @@
urlpatterns = patterns('',
# Examples:
url(r'^$', 'pickaplace.pick.views.home', name='home'),
+ url(r'^venue_search/', 'pickaplace.pick.views.venue_search', name='venue_search'),
# url(r'^pickaplace/', include('pickaplace.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:

0 comments on commit 670d5a1

Please sign in to comment.
Something went wrong with that request. Please try again.