How to reference embedded view component meta name from the embedded view

How can an embedded view reference it’s parent container’s name (the name of the Embedded View component the view is embedded in)? self.parent.name, self.parent.meta.name, ‘self.view.parent.meta.name’, and more variations with additional .parent parts appended all seem to fail when they try to reach above the view itself. Is there a way to do this?

Use case: we have an embedded view with a name that forms the beginning of the name of several related components (their names are bound to their related embedded view container’s name with a suffix added) for each instance of the embedded view. For example, we could have motor1, motor1Ctrl, and motor1CtrlLeader. We’d like to send a message from motor to affect motor1Ctrl and motor1CtrlLeader, but not motor2Ctrl and motor2CtrlLeader. Is there a way for the view inside motor1 embedded view container to find it’s container’s motor1 name for use in system.perspective.sendMessage?

Is there a better way to do this?

It does not sound like that it possible to me; I think it is only possible to gather metadata from the view that is being embedded in the Embedded View component, not the other way around. Think of it like a box: you can take things out of the box, but the things inside the box cannot grab things from outside the box.

If you could make things a little bit more clear with some visualization, it would probably help to see if this is possible or not.

1 Like

I don’t know if you can do exactly what you’re asking, but I think you can accomplish your goal using an input parameter on the view.

1 Like

Thanks @obober, I suspected this might not be possible but thought I should check in case I was missing something. I would be nice if embedded views could reach up to the container they’re embedded in as I’m finding more cases where we have to apply things to the embedded view container rather than relying on the centrally managed embedded view’s internal configuration to handle everything for all instances. For example, if we want button hover drop shadows to display without leaving room for them in the embedded view, we have to set overflow to display on each embedded view container. If the embedded view could reach up to the container, a script in the embedded view itself would handle this to limit outside configuration to view parameters.

@zacht, thanks for the suggestion. For now we’ve used a rootTagPath parameter two of the three related views have in common to filter message application. This meant we had to bind the rootTagPath to the third component which didn’t otherwise need it, which was easy with copy/paste bindings, but annoying. Your suggestion requires similar extra configuration (binding input param to meta.name), but only on the originating component. And it allows targeting other components by name as originally intended, eliminating the need to bind other data to them just to ID them. As component names are unique it would also allow sending a message from the embedded view instance to its embedded view container to set required styles without the possibility that another component we don’t want to target might share some other piece of data we would otherwise identify the target by.