http://p5js.org/reference/#/p5/createSlider says “Appends to the container node if one is specified, otherwise appends to body.”
A. how is it specified? It doesn’t seem to be any of the arguments
B. how do I get a valid reference to a container node? I was hoping I could pass in what is returned form document.getElementByID(); and have my little elements tucked away neatly elsewhere on the page
Frustrating how ambiguous this is - I tried a few logical guesses but nothing worked.
(FWIW, I am working in global mode but preferring to use my own canvasParent etc)
In general, any best practice for “bundle this bunch of DOM library elements outside the main canvas” would also be appreciated!
So if my js memory (and messing around in console) is correct, createElement doesn’t append it as a child to anything. So if I createSlider, is there anyway to attach it to a node I access via that select() function?
heh, posted it just as you were writing
It seem a little odd to have an element attached to the body and then rip it out and assign its parent, but I can work with it.
Actually you can even leave out the quote marks and rely on the trick of how browsers give you global variables named the same as the id of elements! But that seems a little sketch-y (no pun intended)
I almost forgot about that 1. I remember I did some experiments w/ it a long time ago.
Another thing we can do is to create custom tags, like <dog></dog>, <cat></cat>, etc., and use p5.Element::select() to find the custom tag w/o any prefix to its name.
Yeah, as I get a little further into this (simple toy app in global mode, with a few fixed input elements) I realize that there’s very little reason to even use the p5 Dom library. (I think I got excited by the sliders and colorPicker forgetting those are now part of html5) I can use oldschool onchange callbacks in elements I create and have full control. (For example I wanted a textarea and it’s not even clear the DOM library supports that)
Heh, after 15 years of Processing and P5 I’d need a big ol’ page for “You Might Not Need P5” like I have for “You Might Not Need JQuery”. My understanding of what I like in the traditional P5 library and what can be found more or less native in standard canvas browser support is very weak.
(For instance, I can’t quite find the equivalent of p5.dom’s .input() for color picker - one that updates for each color selection, not just when the color picker is closed (on macs it doesn’t auto close))