Skip to content

Best Practice for Server --> Client via Scriptlets, onSelectionChange #188

@semireg

Description

@semireg

If I add a property to a template in ui.js such as:

  const template = HtmlService.createTemplateFromFile('sidebar');
  template.uuid = 'abc123';
  const html = template.evaluate();
  html.setTitle('My Sidebar');
  SpreadsheetApp.getUi().showSidebar(html);

How do I access "uuid" in React via Scriptlets?

I've tried modifying sidebar/index.html

<script>
      window.uuid = JSON.parse(<?= uuid ?>);
      console.log(`window.uuid:${window.uuid}`);
</script>

But I'm not seeing anything. It's probably obvious... 😄

On another note... is there any way to push data from server to client when onSelectionChange is called?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions