From a9b034637bd982c1c3e8d0e8d2288911ae8cc1b4 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Wed, 30 Sep 2015 13:55:23 +0800 Subject: [PATCH] only autocomplete topic/synapse if the user types more than 2 characters --- app/assets/javascripts/src/Metamaps.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js index 2a378623..af0518d0 100644 --- a/app/assets/javascripts/src/Metamaps.js +++ b/app/assets/javascripts/src/Metamaps.js @@ -665,8 +665,11 @@ Metamaps.Create = { }); // initialize the autocomplete results for the metacode spinner - $('#topic_name').typeahead([ + $('#topic_name').typeahead( { + minLength: 2, + }, + [{ name: 'topic_autocomplete', limit: 8, template: $('#topicAutocompleteTemplate').html(), @@ -674,8 +677,8 @@ Metamaps.Create = { url: '/topics/autocomplete_topic?term=%QUERY' }, engine: Hogan - } - ]); + }] + ); // tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete $('#topic_name').bind('typeahead:selected', function (event, datum, dataset) { @@ -724,8 +727,11 @@ Metamaps.Create = { }); // initialize the autocomplete results for synapse creation - $('#synapse_desc').typeahead([ + $('#synapse_desc').typeahead( { + minLength: 2, + }, + [{ name: 'synapse_autocomplete', template: "
{{label}}
", remote: { @@ -745,8 +751,8 @@ Metamaps.Create = { }, engine: Hogan, header: "

Existing synapses

" - } - ]); + }] + ); $('#synapse_desc').bind('typeahead:selected', function (event, datum, dataset) { if (datum.id) { // if they clicked on an existing synapse get it