 Backbone.Factlink ||= {}
 class Backbone.Factlink.TextInputView extends Backbone.Marionette.ItemView
   events:
-    'click': 'focusInput'
     'keydown .typeahead': 'parseKeyDown'
-    'keyup .typeahead': 'updateModel'
-    'input .typeahead': 'updateModel'
+    'keyup .typeahead': '_updateModel'
+    'input .typeahead': '_updateModel'
 
   triggers:
     'focus .typeahead': 'focus'
     'blur .typeahead': 'blur'
+
+  ui:
+    inputField: '.typeahead'
 
   templateHelpers: =>
     placeholder: @options.placeholder

      e.preventDefault()
      e.stopPropagation()

  updateModel: -> @model.set text: @$inputField().val()
  updateHtml: ->
    if @model.get('text') != @$inputField().val()
      @$inputField().val(@model.get('text'))

  enable: -> @$inputField().prop 'disabled', false
  disable: ->@$inputField().prop 'disabled', true

  $inputField: -> @$('.typeahead')

  template: 'generic/text_input'

  initialize: ->
    @listenTo @model, 'change', @_updateHtml

  focusInput: ->
    _.defer => @ui.inputField.focus()

  parseKeyDown: (e) ->
    eventHandled = false
