pharoseaside

Can a child component use updateRoot: to add javascript


I'm using seaside 3.4.8 and a component seaside-plotlyjs to make a javascript plot. This component uses the updateRoot: selector to add in a link to the plotly javascript bundle. Everything is fine until I make the component a child of another component, in which case the plotly library is no longer added to the site. If I take the contents of the updateRoot: selector and move it into the root component, then it works again. Is it possible to have the updateRoot: selector be independent of whether my component is the root or a child of another one to improve the composability of my components?

ChildComponent>>updateRoot:

updateRoot: anHtmlRoot

super updateRoot: anHtmlRoot.
anHtmlRoot javascript url: 'https://cdn.plot.ly/plotly-2.4.2.min.js'

RootComponent>>updateRoot:

updateRoot: anHtmlRoot

super updateRoot: anHtmlRoot.

anHtmlRoot stylesheet url:
    'https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css'.
anHtmlRoot stylesheet url:
    'https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css'.

Solution

  • Did you implement a children method on RootComponent that returns the child component ?

    Seaside will use the result of the children method to know the component tree. A common mistake is to forget this method as many parts of Seaside work just fine without it returning all child component instances.