When you associate a function to a input listener (e.g. the :input
property of a hoplon/input
), what is the type that comes in there? I'm getting an error trying to use that value and when I print what comes into my anonymous function, I get [object Event]
.
@jamesvickers19515 so are you providing a function to :input
? Functions are for eventโs. like :click
I assume you are wanting something like :change #(reset! some-cell @%)
remember you arnโt reading from the DOM, you are responding to DOM events
Right, I'm trying to do a listener for an HTML input
. I changed my handler function to be on :change
instead of :input
. My code looks something like this:
(def principal-input
(h/input
:id :principal :type "number" :min "1.00"
:max "1000000000"
:step "0.01" :value balance-cell :change #(reset! balance-cell @%)))
...where balance-cell
is defined as a var bound to a javelin cell
. But when I change the HTML input
(e.g. click on up/down arrows), I get an error:
Error: No protocol method IDeref.-deref defined for type object: [object Event]
I believe I did have it working at some point as an anonymous function on :input
; does that seem surprising?
Im not familiar with the input event, I always use the changed event, are you including hoplon.jquery
in your ns?
@jamesvickers19515 #(.log js/console %)
for debugging events - use the native console functionality or you just get useless JS object serialization logic
IDeref
is implemented for events in hoplon.jquery
so will not work until you include that ns as mentioned ^^
(extend-type js/jQuery.Event
cljs.core/IDeref
(-deref [this] (-> this .-target js/jQuery .val)))
you can see it's just a shortcut for calling $(this).target.val()
so is entirely optional if you want to work against the event directly
@hiskennyness i sense a blog post coming on ๐ sounds like you have experience on both sides of the fence
Thanks everyone; the problem was indeed that I wasn't including hoplon.jquery
into my namespace. I recently removed that inclusion during refactoring, since there were no usages; I didn't realize it had implicit usages. As for :input
vs :change
, it looks like :change
is fired when the value changes either by the arrow spinners or typing in a new value and pressing enter, while :input
changes from arrow spinners and any keystroke into the input box.
@jamesvickers19515 the hoplon.jquery
ns is what we call an attribute provider, it handles how attributes should be processed. Otherwise hoplon just uses the native js functionality. You can read more about them on the wiki:
https://github.com/hoplon/hoplon/wiki/HTML-Attributes-and-JS-Events
https://github.com/hoplon/hoplon/wiki/Attribute-Providers
Close! It will be a Clojure-NYC talk Jan 17, 2018: https://www.meetup.com/Clojure-NYC/ Not much React-bashing since I can just refer folks to thems that know more than I on existing web frameworks: https://www.infoq.com/articles/more-than-react-part-i and https://github.com/ThoughtWorksInc/Binding.scala and https://www.mendix.com/blog/making-react-reactive-pursuit-high-performing-easily-maintainable-react-apps/โฆ what the MobX crew misses is that they do not need ReactJS anymore. The binding.scala effort and Hoplon/Javelin have that right.
Heh-heh, not sure I linked the above to @thedavidmeister very effectively. I blame #slack.
hiskennyness "fine-grained dataflow" i like it
Are there more examples out there for using hoplon.svg
? Made a polyline plot from the example (`plotSVG`), wanting to add axes labels, tick marks, plot title, etc.
@jamesvickers19515 not really, there are special cases when it comes to SVG, like using :xlink/*
and :svg/*
attributes since jquery doesnt handle CamelCase attributes
it has been used previously tho
let us know when you run into issues so we can document it ๐
Just updated the wiki homepage to make it look like itโs actually a relevant place to go for information ๐
@flyboarder thanks, it seems kind of hard or tedious to do line charts with that svg library, think I'm gonna try http://thi.ng/geom
That came out wrong, my goal is to make 2D line charts and so I probably want something kind of tailored to that :)