         @$('input').on 'typeahead:selected', (event, requestId) =>
             @hide()
             app.router.navigate "/request/#{ requestId }", { trigger: true }
-            
+
     reset: ->
         @$('input').val ''
         @$('ul').removeClass 'dropdown-menu-hidden'
         @$('li').remove()
 
     show: ->
-        @reset()
-        @$el.parent().addClass 'global-search-active'
-        @$('input').focus()
+        @requests.fetch().done =>
+            @reset()
+            @$el.parent().addClass 'global-search-active'
+            @$('input').focus()
 
     hide: (event) ->
         if event?

View = require './view'

class GlobalSearchView extends View



            @lastSearchQuery = query

            fuse = new Fuse(
                @requests.toJSON()
                keys: ["request.id"]
                threshold: 0.6
                id: "request.id")
            results = fuse.search(query)

            process results.slice(0, 10)

        # Debounce event so we don't spam the server
        sourceFunction = _.debounce sourceFunction, 200

        @$('input').typeahead
            highlight: true
        ,
            source: sourceFunction
