     # Remove tag when pressing backspace and input search is empty
     if e.keyCode is @keyCode.BACKSPACE and e.currentTarget.value is ''
       @removeLocationBadge()
-      @destroyAutocomplete()
+      # @destroyAutocomplete()
       @searchInput.focus()
     else if e.keyCode is @keyCode.ESCAPE
       @restoreOriginalState()
     else
       # Create new autocomplete if hasn't been created yet and there's no badge
-      if !@catComplete? and @locationBadgeEl.is(':empty')
-        @createAutocomplete()
+      if @autocomplete is undefined
+        if !@locationBadgeEl.children().length
+          @createAutocomplete()
+      else
+        # There's a badge
+        if @locationBadgeEl.children().length
+          @destroyAutocomplete()
 
   onSearchInputFocus: =>
     @wrap.addClass('search-active')

    location.href = result.url

  destroyAutocomplete: ->
    @catComplete.destroy() if @catComplete?
    @catComplete = null

  createAutocomplete: ->
    @query = "?project_id=" + @projectId + "&project_ref=" + @projectRef

    @searchInput.catcomplete
      appendTo: 'form.navbar-form'
      source: @autocompletePath + @query
      minLength: 1
