Skip to content

<script> sections not being called when component is late rendered #436

@martindemello

Description

@martindemello

I have several components of the form

  <div>
    {{ round_pairing | json_script:"round-pairings-data" }}
    <div unicorn:ignore id="tabulator-table"></div>
    <script src="{% static "tournament/round_pairings.js" %}"></script>
  </div>

which load data for a table and then call a javascript function to populate it in the tabulator-table div. The javascript file is different for each component, and calls makeTable() at top level at the end.

This works fine when I include a component directly in a page. Now I'm trying to write a tab view, with the parent looking like

      <div>
          <a href="{% url 'tournament:round_pairings' tournament.id div.id %}"
            unicorn:click.prevent="set_active({{div.id}}, 'round-pairings')"
          >Round Pairings</a>
          {% if active_view %}
          {% unicorn active_view division=active_division parent=view key=active_key %}
          {% endif %}
      </div>

where active_view is the name of the child component, and it looks like the javascript is never getting loaded, and furthermore that any script tags in the child component are not getting executed.

I suspect this is the same issue as #243 and that there's no good solution, but filing this just in case there's been a fix or some better way of doing things.

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