Can we render child views dynamically on some even...
# suitecommerce
a
Can we render child views dynamically on some events in kilimanjaro?
p
Yes you can
well, i'd say have the view always render, and react to events. that's simpler (and wrap all the template in an "isReady" clause for example that only fulfills after the event hapened/the data you are looking for is finally there in your model)
s
Pablo is right. It's usually easier to always have the views render and then have its content change depend on your circumstances (by default it is blank but
if x == true
then it renders some output. But yes, it is possible.
a
Thank you Pablo and steve for the update. But, is there any module using dynamic rendering in SCA?
s
Depends what you mean by 'dynamic rendering'. I talk about contextually rendering a view in this blog post: https://developers.suitecommerce.com/use-helper-files-services-and-contextual-rendering-in-your-extension#title4
This is an example of some code in a view:
Copy code
, render: function () // this will overwrite the inherited render() method
    {
      // "How do I conditionally do something based on what the current view is?"
      if (this.parentView instanceof OrderHistoryListView)
      {
        this._render(); // this is the 'real' method
      }
      // by doing nothing if it is false, it won't render on pages that aren't the order history list view
    }
a
Thank you so much