mozilla / nunjucks

A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)
https://mozilla.github.io/nunjucks/
BSD 2-Clause "Simplified" License
8.48k stars 635 forks source link

script not loading after navigate from one page to another page nunjucks #1380

Open bytes-karnav opened 2 years ago

bytes-karnav commented 2 years ago

i am creating website using nunjucks and express, its king of blog website and content coming from prismic. i want to load one script file for active campane form when user navigate from blog list page to any blog detail page, after navigate to detail page. will get script URL from prismic and I want to execute that script in HTML file.

its working while refresh the detail page but its not working when navigate from one page to another pages.

here is some sample code of my website

    ---
layout: _layout.njk
permalink: "/{{ post.blogType }}/{{ post.uid }}/"
pagination:
    alias: post
    data: posts
    size: 1
    addAllPagesToCollections: true
---

{% set params = item.primary.sumo_form_id.split("=") %}
        <div class="_form_{{params[1]}}">
        </div>
        <script src="{{item.primary.sumo_form_id}}" type="text/javascript" charset="utf-8" defer>
        </script>

Before Refresh

Screenshot from 2021-11-08 18-21-51

After Refresh

Screenshot from 2021-11-08 18-22-21

i need after refresh html without refreshing page