           $.noop()
         e.stopPropagation()
 
-      render_view: (datas) ->
-        datas = datas.splice(0, this.get_opt('limit'))
-        datas = _unique(datas, this.data_value())
-        datas = _objectify(datas)
-        datas = @callbacks["sorter"].call(this, @query.text, datas)
-
-        @view.render datas
+      render_view: (data) ->
+        data = data.splice(0, this.get_opt('limit'))
+        data = @callbacks["data_refactor"].call(this, data)
+        search_key = this.get_opt("search_key")
+        data = @callbacks["sorter"].call(this, @query.text, data, search_key)
+
+        @view.render data
 
       look_up: ->
-        key = this.catch_query()
-        return no if not key
-        log "At.look_up.key", key
-
-        if (datas = @methods['filter'].call(this, key))
-            this.render_view datas
-        # else if $.isFunction(callback = @.get_opt 'callback')
-        #     callback key.text, $.proxy(this.render_view,@)
+        query = this.catch_query()
+        return no if not query
+        log "At.look_up.query", query
+
+        origin_data = this.get_opt("data")
+        search_query = this.get_opt("search_query")
+        if typeof data is "string"
+          params =
+            q: query.text
+            limit: this.get_opt("limit")
+          callback = $.proxy(this.render_view, this
+          @callbacks['remote_filter'].call(this, params, callback))
+        else if (data = @callbacks['filter'].call(this, query.text, origin_data, search_query)
+            this.render_view data
         else
             @view.hide()
         $.noop()


      get_opt: (key, default) ->
        try
          @settings[@current_flag][key]
        catch e
          default || null

      data_value: ->
        @data_value || @data_value = $(this.get_opt('tpl'))

      rect: ->
        $inputor = @$inputor

          matched = if match[2] then match[2] else match[1]
        matched

      filter: (query, data, search_query) ->
        if $.isArray(data) and data.length != 0
          items = $.map data, (item,i) =>
            try
              name = if $.isPlainObject item then item[search_query] else item
              regexp = new RegExp(query.replace("+","\\+"),'i')
              match = name.match(regexp)
            catch e
              return null
            return if match then item else null
        items

      remote_filter: (params, url, render_view) ->
        $.ajax url, params, (data) ->
          names = $.parseJSON(data)
          render_view(names)

      tpl_eval: (tpl, map) ->
        try
          el = tpl.replace /\$\{([^\}]*)\}/g, (tag,key,pos) ->
            map[key]
        catch error
          ""

      highlighter: (li, query) ->
        return li if not query
        li.replace new RegExp(">\\s*(\\w*)(" + query.replace("+","\\+") + ")(\\w*)\\s*<", 'ig'), (str,$1, $2, $3) ->
            '> '+$1+'<strong>' + $2 + '</strong>'+$3+' <'

      sorter: (query, items, search_key) ->
        results = []

        for item in items
          text = item[search_key]
          continue if text.toLowerCase().indexOf(query) is -1
          item.order = text.toLowerCase().indexOf query
          results.push(item)

        results.sort (a,b) ->
          a.order - b.order
        return results

      data_refactor: (data) ->
        $.map data, (item, k) ->
          if not $.isPlainObject item
            item = {id:k, name:item}
          return item


    class At
