[jayq] "No protocol method ISeqable.-seq" for result of (children $xx) call

90 views
Skip to first unread message

Torbjørn Vatn

unread,
Nov 19, 2012, 6:15:13 AM11/19/12
to clj-...@googlegroups.com
I've got some problems using Jayq's children function

Here's my code:

(defn print-image [letter]
  (let [$children (children ($ :#bilde))]
  (.log js/console (count $children)) ...

Here's the resulting javascript:

alpha_card.client.main.print_image = function() {
var a = jayq.core.children.call(null, jayq.core.$.call(null, "\ufdd0'#bilde"));
console.log(cljs.core.count.call(null, a))

And this is the resulting error message:

  1. Uncaught Error: No protocol method ISeqable.-seq defined for type object: [object Object] bootstrap.js:1388
    1. cljs.core.missing_protocolbootstrap.js:1388
    2. cljs.core._seqbootstrap.js:2261
    3. cljs.core.seqbootstrap.js:2938
    4. cljs.core.accumulating_seq_countbootstrap.js:3067
    5. cljs.core.countbootstrap.js:3076
    6. alpha_card.client.main.print_image

Isn't Jayq supposed to return clojure collections that can be used with e.g. the count or filter functions?



Shenyang Zhao

unread,
Nov 19, 2012, 9:57:40 AM11/19/12
to clj-...@googlegroups.com
Maybe you should use

(let [$children($ :#bilde)]

And I think it really help to have a repl connect to the browser for debugging.

regards,
Zhao Shenyang

Shenyang Zhao

unread,
Nov 19, 2012, 10:15:26 AM11/19/12
to clj-...@googlegroups.com
Sorry, miss-read your question. children doesn't work in the repl too. But (.children ($ :#id)) seems to work for me. 

regards,
Zhao Shenyang


On Mon, Nov 19, 2012 at 7:15 PM, Torbjørn Vatn <torb...@vatn.org> wrote:

Torbjørn Vatn

unread,
Nov 19, 2012, 3:22:11 PM11/19/12
to clj-...@googlegroups.com
But the children function from jayq.core does just that: 

(defn children
  ([$elem selector]
     (.children $elem (name selector)))
  ([$elem]
     (.children $elem)))

and I still get the same ISeqable.-seq error if I replace jayq.core.children call with .children

Torbjørn Vatn

unread,
Nov 20, 2012, 3:48:03 PM11/20/12
to clj-...@googlegroups.com
I had to resort to using the .size javascript function like this

(defn print-image [letter]
  (let [$children (children ($ :#bilde))]
   (if (= (.size $children) 0) ...

I was hoping to be able to handle the result as a clojure collection, but it seems like  the cljs.core._seq function sees $children as an Object not an ISeqable

Torbjørn Vatn

unread,
Nov 22, 2012, 1:54:00 AM11/22/12
to clj-...@googlegroups.com
After doing some more research I discovered that it was noir-cljs that caused the problems. When I changed to using lein-cljsbuild everthing works as expected.

Will try to compare the JS-output from the two solutions to see if I can locate the problem in noir-cljs.

Chris Granger

unread,
Nov 22, 2012, 1:55:56 AM11/22/12
to clj-noir
noir cljs uses an ancient build of clojurescript. Better off just sticking with lein-cljsbuild.

Cheers,
Chris.
Reply all
Reply to author
Forward
0 new messages