     @gmap.onSucceed.push (address)=>
       $(@selector).val address
 
-  source: ()->
-    (request, response) =>
-      @gmap.searchGeocodes request.term, (results)->
-        response $.map results, (item) ->
-          label: item.formatted_address
-          value: item.formatted_address
-          geocode: item
+  source: (request, response) =>
+    @gmap.searchGeocodes request.term, (results)->
+      response $.map results, (item) ->
+        label: item.formatted_address
+        value: item.formatted_address
+        geocode: item
 
-  select: ()->
-    (event, ui) =>
-      @gmap.update ui.item.geocode
+  select: (event, ui) =>
+    @gmap.update ui.item.geocode
 
   afterApply: ()->
     @syncWithMap()

root = exports ? this

class root.Autocomplete
  source: ()->
    []
  select: ()->
    ()->
  change: ()->
    ()->
  minChars: 2

  constructor: (@selector)->


  apply: ()->
    $(@selector).autocomplete
      source: @source
      select: @select
      change: @change
    this.afterApply()

  afterApply: ()->
