Hi All, 

I'm trying to use the google autocomplete widget in cljs and having 
problems converting the google basic example into cljs.

This is the original:

goog.ui.AutoComplete.Basic = function(data, input, opt_multi, 
opt_useSimilar) {
  var matcher = new goog.ui.AutoComplete.ArrayMatcher(data, 
!opt_useSimilar);
  var renderer = new goog.ui.AutoComplete.Renderer();
  var inputhandler =
      new goog.ui.AutoComplete.InputHandler(null, null, !!opt_multi);

  goog.ui.AutoComplete.call(this, matcher, renderer, inputhandler);

  inputhandler.attachAutoComplete(this);
  inputhandler.attachInputs(input);
};
goog.inherits(goog.ui.AutoComplete.Basic, goog.ui.AutoComplete);

I've tried various ways of adapting this into cljs, but without success. 
For example

(defn ac-fn [lookup-fn input]
  (let [renderer (goog.ui.AutoComplete.Renderer.)
        ih (goog.ui.AutoComplete.InputHandler. nil nil false)]
    (this-as ctx
*      (.call goog.ui.AutoComplete ctx lookup-fn renderer ih)*
      (doto ih
        (.attachInputs input)
        (.attachAutoComplete ctx)))))

The problem is the 'this' reference, which resolves to the window instead 
of the function itself, which seems to be what is required here. I have 
tried all sorts of different forms, but can't work out how to do this, and 
I can't find any examples which help.

I'm probably going about this in the wrong way, and I'm sure the right way 
is obvious, but not to me :>) Can anyone point me in the right direction?

Best wishes

John

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to