         nextItem.makeItemActive()
     else
       @items[0]?.makeItemActive()
-    
+
   goUp:()->
     activeItem = @getActiveItem()
     if activeItem.index?

      title: ''
    }, options
    super options
    
  focus:(pubInst,event)->
    (@getSingleton "windowController").setKeyView @
    
  viewAppended: ->
    # log 'view appended'
    @list = new MultipleInputListView delegate: @
    @addSubView @list
    
  $input:()-> @$().find("input.main").eq(0)
  
  getValues: ->
    @_values
    
  rearrangeInputWidth: ->
    no
    
  addItemToSubmitQueue: ->
    super
    @inputAddCurrentValue()
    
  keyUp: (event) ->
    if event.keyCode is 13
      @inputAddCurrentValue()
      
    super
    
  inputRemoveValue: (value) ->
    index = @_values.indexOf value
    if index > -1
      @_values.splice index, 1
      
    @_inputChanged()
    
  clear: ->
    @_values = []
    @removeAllItems()
    @_inputChanged()
    
  inputAddCurrentValue: () ->
    value = @$input().val()
    value = $.trim value

    return if value in @_values or value is ''
    
    @_values.push value
    @$input().val ''
    @list.addItems [value]
    
    @_inputChanged()
    
  _inputChanged: ->
    if not @_hiddenInputs
      @_hiddenInputs = []
      
    #remove old inputs
    for input in @_hiddenInputs
      input.destroy()
      
    inputName = @getOptions().name
    for value, index in @_values
      newInput = new KDInputView type: 'hidden', name: inputName + "[#{index}]", defaultValue: value
      @_hiddenInputs.push newInput
      @addSubView newInput
      
    @handleEvent type: 'MultipleInputChanged', values: @getValue()
  
  click: (event) ->
    if $(event.target).hasClass 'addNewItem'
      @inputAddCurrentValue()
    
  
  setDomId:()->
    @$input().attr "id", @getDomId()
    @$input().data "data-id", @getId()
    # @$input().attr "name", @getName()
  
  setDomElement: ->
    # <p class='search-tags clearfix'><span>Ryan <cite>x</cite></span></p>
    @domElement = $ "<div class='filter kdview'>

      callback      : =>
        view = @getView()
        view.$input().trigger('focus')

    dropdownListView.on 'ItemWasAdded', (view, index)=>
      view.registerListener
        KDEventTypes  : 'KDAutoCompleteSubmit'
