Skip to content

Commit

Permalink
add logic to remove all script of current page before moving to new page
Browse files Browse the repository at this point in the history
  • Loading branch information
namnguyen20999 committed Dec 30, 2024
1 parent 359fef6 commit 50790ce
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions frontend/taipy-gui/src/components/pages/TaipyRendered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ const setStyle = (id: string, styleString: string): void => {

// set script tag for the page
const setScript = (id: string, scriptPaths: string[]): void => {
document.querySelectorAll(`script[id^="${id}_"]`).forEach(script => script.remove());
scriptPaths.forEach((path, index) => {
let script = document.getElementById(`${id}_${index}`) as HTMLScriptElement | null;
if (!script) {
script = document.createElement("script");
script.id = `${id}_${index}`;
script.src = path;
script.defer = true;
document.head.append(script);
}
const script = document.createElement("script");
script.id = `${id}_${index}`;
script.src = path;
script.defer = true;
document.head.append(script);
});
};

Expand Down

0 comments on commit 50790ce

Please sign in to comment.