Addon Javascript executed three times

English! place to talk about development, programming and coding
Post Reply
Niroc
Znuny newbie
Posts: 18
Joined: 18 Jun 2015, 10:57
Znuny Version: 5.0.12

Addon Javascript executed three times

Post by Niroc »

Hello,

i already searched in the forum but can't find a similiar thread.

I placed my javascript code in the template file under my html code and sourrounded it with: [% WRAPPER JSOnDocumentComplete %] ... [% END %]

My problem is that javascript gets executed three times and when I look in the source code in the browser, the javascript code can be found on three different areas. This explains why it gets executed three times, but why does this happen at all? How can I call it once?

Thanks
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Addon Javascript executed three times

Post by RStraub »

Hi there,

this might depend on the template. I think OTRS renders each article in a separated iframe. There are some solutions for it:
- Use the LayoutObject in the Perl Module to add the code once
- Use a Post-Filter to modify the "finished" HTML
- Use a variable to make sure to execute the code only once...
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Post Reply