Fork me on GitHub

So, I’ve got this problem I’m not sure how to handle. I have a collection in a cell, and I want to render it plus any children it might have. So I’m inclined to do something like this:


In other words, I’ve got a for-tpl that wants to render a single thing, and then possibly a bunch of other things.


But that doesn’t work. It doesn’t like that the first element of that vector is a cell, and the second is an element.


I find the *-tpl macros very confusing. So I’m not really sure how to handle this.


It’s basically a grid, where there are a bunch of items, each of which may have subitems. I want to render a row for each item, then follow that with a row for each of its subitems.


the for-tpl can't wrap the stuff in a div instead of returning a vector?


It’s in a table - I get weird results if I try to wrap a bunch of rows in anything, including a tbody.


I feel like - but can’t definitively state - that the model is inconsistent here. Like, I have this notion of an equivalence between elements and cells, and it breaks when I have a vector containing both.


i don't see why it would break there, exactly


The error is something along the lines of “element is not a Node”.


In that code snippet, it seems to me I’m returning a vector of [(if-tpl …) (td …)]


Which I believe is why it’s choking.


can anyone point me to a demo or gist for handling file uploads with hoplon/castra?


@candera generally i always put my *-tpl in an element


sucks if that breaks the layout for you 😕


Yeah, I thought I could use a tbody, but it doesn’t seem to be working.


@candera i imagine this can be solved somewhere in hoplon by adding a check somewhere...


it would be great if there was some way to deal with this, i tend to defensively nest tpls in divs "just in case" which does lead to a bit of divitis


@candera what's the shape of the data you're trying to render?


Master-detail. So I have an airbase. At each airbase is zero or more squadrons. I want a row for each airbase and below it a row for each squadron.


The airbase row will have a toggle so you can collapse its squadrons.


I managed to get it working by abandoning for-tpl in favor of a straight cell approach, since my data won’t change much and I were confused.


i will try to make a thing, play a bit


Thanks, Alan - I see what you did. Tables within tables isn’t going to work for me, but as is often the case, it makes me question whether I’m doing the right thing in the first place anyway, from a UI standpoint.


I'm having trouble getting values out of an input form. It was working before, but something changed. Currently I'm using UI and passing through Hoplon Hlisp elements.

        (let [mycell (cell "mytext")]
              :type "text"
              :id "mycell"
              :value mycell
              ; :blur
              ; :focus

              ;;;; giving errors!!! (cannot deref callback?)
              :input #(reset! mycell @%))
              ; :change #(reset! mycell @%))
              :for "mycell" 
              :value (cell= mycell)))))
I get an error in the console when I start typing or tab out of the field.
core.cljs:272 Uncaught Error: No protocol method IDeref.-deref defined for type object: [object Event]
    at Object.cljs$core$missing_protocol [as missing_protocol] (core.cljs:272)
    at Object.cljs$core$_deref [as _deref] (core.cljs:573)
    at cljs$core$deref (core.cljs:1351)
    at HTMLInputElement.<anonymous> ((index):640)
cljs$core$missing_protocol @ core.cljs:272
cljs$core$_deref @ core.cljs:573
cljs$core$deref @ core.cljs:1351
(anonymous) @ (index):640


Seems like there is something going on with derefing the callback to extract the value.


@jumblerg I couln't figure out how to get the value out of a (line) input function to print or submit it or update a cell. Do you have a simple example of the UI way to do the above?


@chromalchemy looks like IDeref isn't being extended to that Event object for some reason. perhaps try #(println (.. % -target -value))


or rather, #(.log js/console %)


then you can inspect the mysterious object in console and figure out how to peel the value off it