From c427e7fd7eb1f7f766657dfc300af44251d01b9c Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Fri, 5 Feb 2016 19:54:38 +0800 Subject: [PATCH] mess with typeahead(val) calls. looks like the header is being destroyed during suggestion rendering, need a variable --- app/assets/javascripts/src/Metamaps.GlobalUI.js.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb index ecf4a4ac..19681df9 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js.erb @@ -450,7 +450,7 @@ Metamaps.GlobalUI.Search = { var self = Metamaps.GlobalUI.Search; self.timeOut = setTimeout(function () { - if (!self.locked && !self.changing && self.isOpen && (bypass || $('.sidebarSearchField').typeahead('val') == '')) { + if (!self.locked && !self.changing && self.isOpen && (bypass || $('.sidebarSearchField.tt-input').val() == '')) { self.changing = true; $('.sidebarSearchField, .sidebarSearch .tt-hint').css({ padding: '7px 0 3px 0', @@ -600,7 +600,7 @@ Metamaps.GlobalUI.Search = { // make sure that when you click on 'limit to me' or 'toggle section' it works $('.sidebarSearchField').bind('typeahead:change', function(){ - if ($(this).typeahead('val') === '') { + if ($('.sidebarSearchField.tt-input').val() === '') { self.hideLoader(); } else { @@ -643,7 +643,9 @@ Metamaps.GlobalUI.Search = { $('.limitToMe').unbind().bind("change", function (e) { // set the value of the search equal to itself to retrigger the autocomplete event self.isOpen = false; - $('.sidebarSearchField').typeahead('val', $('.sidebarSearchField').typeahead('val')); + var searchQuery = $('.sidebarSearchField.tt-input').val(); + $(".sidebarSearchField").typeahead('val', '') + $(".sidebarSearchField").focus().typeahead('val', searchQuery).focus(); setTimeout(function () { self.isOpen = true; }, 2000);