add typeahead for tournament names
[mlpccg-meta.git] / meta / static / js / main.js
index 4df27d2..a2614b3 100644 (file)
@@ -3,3 +3,19 @@ function rateDeck() {
         console.log(data);
     });
 }
+
+var tournaments = new Bloodhound({
+  datumTokenizer: Bloodhound.tokenizers.obj.nonword('name'),
+  queryTokenizer: Bloodhound.tokenizers.nonword,
+  prefetch: '/meta/tournaments'
+});
+
+tournaments.initialize();
+
+$(document).ready(function() {
+    $('.typeahead-tournaments').typeahead(null, {
+        name: 'tournaments',
+        displayKey: 'name',
+        source: tournaments.ttAdapter()
+    });
+});