       data[option]()
 
 $.fn.autocomplete_collection.defaults =
-  collection_ui: '<ul class="autocomplete-collection"></ul>'
+  collectionUi: '<ul class="autocomplete-collection"></ul>'
   items: 8
   menu: '<ul class="autocomplete_collection dropdown-menu"></ul>'
   item: '<li><a href="#"></a></li>'

    @$collection.append $li
    @$element.val ""


  add: (val) ->
    if i = @index_in_collection(val.id) == -1
      @draw(val)
      @collection_add(val)

  setValue: ->
    @$hidden.val JSON.stringify @collection
    # @$hidden.val $.map(@collection, (o) -> "'#{o.id.toString()}'" ).join(",")

  collection_add: (val) ->
    @collection.push(val)
    @setValue()

  collection_remove: (i) ->
    @collection.splice i, 1
    @setValue()

  collection_reorder: (ids) ->
    that = @
    ordered_collection = []
    for id, i in ids
      do (id) ->
        index = that.index_in_collection(id)
        val = that.collection[index]
        val.position = i + 1
        ordered_collection.push val
    @collection = ordered_collection
    @setValue()

  remove: (val) ->
    if (i = @index_in_collection(val.id)) > -1
      @collection_remove(i)
      @$collection.find("[data-autocomplete-collection-id='#{val.id}']").remove()

  build: ->
    that = @

        return i[0]
    items.first().addClass('active')
    @$menu.html(items)
    if @allowNew
      $addNewLi = $(@options.item)
      $addNewLi.find("a").addClass('add-new icon-plus').html("Add new item")
      @$menu.append $addNewLi
    @

  next: (event) ->
