     @on 'search:closed', @hideSuggestions
     @on 'search:cursorchanged', @ensureResult
 
-    
+
     @autoselect = false if @enableSpotlightAutocomplete
     @setupTypeahead()
     @setupPlaceholder()

    _.each ['opened', 'closed', 'selected', 'cursorchanged'], (action) =>
      @$input.on "typeahead:#{action}", (args...) =>
        @trigger "search:#{action}", args...
  
    templateOptions = {
      suggestion: @suggestionTemplate
      empty: -> "" # Typeahead won't render the header for empty results unless 'empty' is defined


  selectResult: (e, model) ->
    return @emptyItemClick() unless model

    if model.collection and model.collection.models
      analyticsHooks.trigger 'search:item:click',
        query: @query
        item_number: model.collection.models.findIndex( (result) -> return result.id == model.id ) + 1
        item_type: model.get('display_model')
        item_id: model.get('_id')
        destination_path: "#{sd.APP_URL}#{model.href()}"

    @selected = true
    location.assign model.href()

