Closed MrSorcus closed 6 years ago
Ok, I agree that there should be a support for element place βΒ I'll add that.
Thank you so much. But what about β2 (How to insert multiple elements to page with place without div (or any other) container.)?
Sure, that should also be possible β give me a few hours, our baby just woke up πΌπΆ
Ok, i understand. Thanks you again. :smile:
I started to create Node array support, however since mount
doesn't support mounting multiple nodes inside a component, I give up for now..
place
need to have a single Node in el
to be able to remount.
I will probably add support for mounting elements with multiple nodes, since it has been requested for list
s as well, so let's see..
protip: you can combine place
and list
like this:
this.mylist = place(list.extend('.mylist', MyItem, '_id', { i18n }));
...
this.mylist.update(visible, data);
list.extend
returns basically a View class.. π
protip: you can combine place and list like this:
How to insert multiple elements to page with place without div (or any other) container.
Maybe useful, but not for this...? Because container (div element) still exist with list
too.
A little question. place() currently doesn't support this?
place(
el(".first"),
el(".second")
)
Sorry for the inconvenience...
No, the issue is that place
needs a single Node in el
to be supported with mount
etc.
I will investigate that further in some later time.
You could however create your own custom component to support showing/hiding multiple Nodes.
Ok, understand.
Another one question. place() doesn't remember position of element.
Steps to reproduce.
const {
el,
mount,
place
} = redom
this.el = el("",
el(".first", "First"),
this.place = place(el(".second", "Second")),
el(".third", "Third")
)
mount(document.body, this.el)
this.place.update(true)
this.place.update(false)
this.place.update(true)
Result:
<div>
<div class="first">First</div>
<div class="third">Third</div>
<div class="second">Second</div>
</div>
Thanks for letting know, there was a bug which is now fixed! πͺ
place
works so that if the visibility value has changed to true, it replaces a placeholder with the element:
https://github.com/redom/redom/blob/44f055fae8824a6b1e336340073325d1a91f3c22/src/place.js#L32-L33
if it's changed to false, it replaces the element with the placeholder again: https://github.com/redom/redom/blob/44f055fae8824a6b1e336340073325d1a91f3c22/src/place.js#L51-L52
(the third value of mount
is the before
value, like insertBefore vs. appendChild)
The placeholder is just an empty text node: https://github.com/redom/redom/blob/44f055fae8824a6b1e336340073325d1a91f3c22/src/place.js#L14
π
Thanks for this detailed answer. I'm very happy with this library. :heart_eyes:
I'm happy to hear that! I use RE:DOM daily in my own projects (also client work), in production as well. It's powering for example a digital signage platform both in manager and players.
Performance and memory-efficiency are top priority, since we're using low-end devices as well. And RE:DOM's been doing quite all right π
What a simple/right way to show or hide single elements on page without changing their style? For example, simple form with input fields, which depends on some user actions. I'm not sure that inserting all of this inputs with
display: none
to page is a good idea. I know aboutplace
, but create components for each single elements (like an input element) is not a best solution. And now we're returning to this issue.How to show/hide inputs with id 2-4?
display: none/block
?this.input.style.display = "none/block"
- use it every time when i want to display/hide it?How to insert multiple elements to page with
place
withoutdiv
(or any other) container.Here
div
container not needed, but i don't know how to add this inputs without it.Thanks for answer.