These are chat archives for ractivejs/ractive

12th
Jan 2018
kouts
@kouts
Jan 12 2018 07:29
Is there any way to attach a component to an instance without using an anchor?
Chris Reeves
@evs-chris
Jan 12 2018 07:31
as in the component already exists?
kouts
@kouts
Jan 12 2018 07:37
no it is created on the fly and what I want is to attach it to let's say the el of the main instance.
What I do now is on the main intance
oncomplete: function(){
    this.popupconfirmation = new Ractive.components.popupconfirmation({
    el: this.el,
    append: true
});
and then I destroy the component on teardown
Chris Reeves
@evs-chris
Jan 12 2018 07:39
For stuff like that, I usually let the parent instance manage the lifecycle
and in init do something like this.popup = this.findComponent('popup')
kouts
@kouts
Jan 12 2018 07:40
I'm using this because I have no way of going to all templates and put an <popupconfirmation /> tag
Chris Reeves
@evs-chris
Jan 12 2018 07:40
ah
kouts
@kouts
Jan 12 2018 07:40
It's like a drop in replacement
for the native js confirm function
That currently works but I thought I'd ask if something else works
Chris Reeves
@evs-chris
Jan 12 2018 07:43
if you don't mind getting a little dirty with the template, you can append the tag in the config event
kouts
@kouts
Jan 12 2018 07:43
hmm how to do that @evs-chris?
Chris Reeves
@evs-chris
Jan 12 2018 07:44
on mobile, so bear with me a minute
kouts
@kouts
Jan 12 2018 07:44
no worries!
Chris Reeves
@evs-chris
Jan 12 2018 07:54
kouts
@kouts
Jan 12 2018 07:55
I'll try this, thanks alot @evs-chris
Chris Reeves
@evs-chris
Jan 12 2018 07:55
basically, shallow copy template array and append an element vdom node to the end
👍
kouts
@kouts
Jan 12 2018 08:41
Thanks @evs-chris that worked!
maybe there should be a separate lifecycle event for messing with the template before render!
Paul Maly
@PaulMaly_twitter
Jan 12 2018 12:35
@kouts Maybe this variant will be little bit cleaner: playground
kouts
@kouts
Jan 12 2018 12:46
Nice one @PaulMaly_twitter !