Could someone with more knowledge than myself with using a ui-template to display an image in D2 have a look at this issue please? The guy thinks that it is a bug but I I suspect it is just a matter of knowing how to do it. The problem is that the image is not retained when the template is not on the current page.
Is the problem that the image is not remaining in tact when the template is moved to a different group or that it will not show anymore when clicking the buttons? Not entirely clear but either way, I used his example and when moving the template node to a new group, the image is still there and can be toggled by the buttons.
I cannot duplicate his issue, so I don't know what's going wrong for him. (browser console output may help)
My understanding is that the issue arises when the template is on a different page to the button invoking it. The image does not then appear when switching to that page. But I may not be understanding fully.
Yeah, I moved the template node first to a new group on the same page, still worked... then moved to a new page entirely (opened in a new window on my second monitor) and it still worked... the image that was sent to the node before moving it to a new page was even still showing when I navigated to the new page in my browser.
Isn't that because D2 removes the "page" that is navigated away from instead of retaining it in the browser? That's why I suggested adding the template to the head instead of the body. A template can be anywhere.
Yes, I think the technique to be used is to watch for messages coming in and save the data, then in mounted() display it. The skeleton code included when a new ui-template is added includes the hooks to do that, and the documentation is pretty good I think.
Seems very complex to me.
![]()