Fork me on GitHub
#hoplon
<
2017-02-14
>
candera00:02:57

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:

candera00:02:11

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

candera00:02:35

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.

candera00:02:51

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

candera00:02:25

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.

micha00:02:23

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

candera00:02:26

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

candera00:02:46

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.

micha00:02:39

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

candera00:02:15

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

candera00:02:39

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

candera00:02:50

Which I believe is why it’s choking.

raywillig00:02:04

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

thedavidmeister01:02:31

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

thedavidmeister01:02:34

sucks if that breaks the layout for you 😕

candera03:02:06

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

thedavidmeister03:02:11

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

thedavidmeister03:02:12

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

alandipert03:02:50

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

candera03:02:21

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.

candera03:02:34

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

candera03:02:56

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.

alandipert03:02:36

i will try to make a thing, play a bit

candera12:02:11

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.

chromalchemy16:02:27

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.

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

              ;;;; giving errors!!! (cannot deref callback?)
              :input #(reset! mycell @%))
              ; :change #(reset! mycell @%))
            (output 
              :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

chromalchemy16:02:07

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

chromalchemy16:02:20

@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?

alandipert17:02:01

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

alandipert17:02:09

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

alandipert17:02:23

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