How do you know the let is working? Is the run-draganddrop function being called by something outside of that source file? It'll have the same problem as the def, you just won't see it when you load the file because the function isn't called.
I looked into goog.jar and goog.fx.DragDrop is an entire namespace, so you need to explicitly require it so ClojureScript will bring it into the compiled JS: (:require [goog.fx.DragDrop :as _] [goog.fx :as fx] [goog.graphics :as graphics]) If you look inside the Closure library jar (goog.jar) at goog/fx/fx.js only requires the following: goog.require('goog.asserts'); goog.require('goog.fx.Animation'); goog.require('goog.fx.Animation.EventType'); goog.require('goog.fx.Animation.State'); goog.require('goog.fx.AnimationEvent'); goog.require('goog.fx.easing'); which is why DragDrop isn't picked up. best, Kevin On Feb 10, 3:44 pm, billh2233 <bill.har...@gmail.com> wrote: > I don't understand (def someVar (newInstantiatedGoogFxObject...)). > Why does (def someVar (new-goog-fx-object ...)) fail whereas (let > [somevar (new-goog-fx-object ...) ] works? > > I'm trying to define a variable using def and instantiate a new > goog.fx.DragDrop, but this clojurescript: > > (def dragSource (fx/DragDrop. "myText" "stuff")) > > produces this javascript and resulting error: > > dom.test.dragSource = (new goog.fx.DragDrop("myText","stuff")); > > -->Uncaught TypeError: undefined is not a function > > whereas the let-based version instantiates and executes just fine: > > (defn run-draganddrop [] > (let [dragSource (fx/DragDrop. "myText" "stuff")] > ... > ) > ) > > ----------------------- > Here is the actual source file: > > (ns dom.test > (:require [goog.fx :as fx] > [goog.graphics :as graphics] > )) > > ;FAILS in the browser. It requires the expression to be a function. > The expression is undefined. > ;IMO the expression should produce a new object and should not be a > function. > (def dragSource (fx/DragDrop. "myText" "stuff")) > > ;SUCCEEDS. > (defn run-draganddrop [] > (let [dragSource (fx/DragDrop. "myText" "stuff")] > ) > ) > > Thanks. Bill -- 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