Hello Team,
I am using the below format in app.js
There is an issue with this format as in customer’s account, once the custom APP is saved by changing few fields in it, it is giving an error.
The error: “app is not defined.”
The same error is not coming in other freshdesk account.
Please let me know if I am missing something.
Regards,
Akhil S K
Santhosh
(Santhosh Balusamy)
January 13, 2023, 9:14am
3
@Akhil_Kulkarni ,
I think you need to wrap the code inside the document-ready method, once all the scripts are loaded (freshclient) and then you need to execute your code.
Thanks
Hello Santhosh,
After “fdk create”, we will get the below file structure.
If we use the document-ready method, the error will be “$ not defined”.
Santhosh
(Santhosh Balusamy)
January 13, 2023, 10:12am
5
you can use like this
document.onreadystatechange = () => {
if (document.readyState === 'complete') {
// your code
}
}
Hope it helps
kaustavdm
(Kaustav Das Modak)
January 16, 2023, 5:54am
6
Saif
(Saif Ali Shaik)
January 16, 2023, 7:04am
7
@Akhil_Kulkarni The value of app
becomes available to the app using
<script async src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script>
in the associated HTML file.
You must ensure that your app.js
starts to execute after fresh_client.js
first executes
<script async src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script>
<link rel="stylesheet" type="text/css" href="styles/style.css" />
</head>
<body>
<div class="main">
<p>Utilize this template code to build your App</p>
<p id="apptext"></p>
</div>
</body>
<script defer src="scripts/app.js"></script>
<script async type="module" src="https://unpkg.com/@freshworks/crayons@3/dist/crayons/crayons.esm.js"></script>
<script async nomodule src="https://unpkg.com/@freshworks/crayons@3/dist/crayons/crayons.js"></script>
</html>
You can ensure it by understanding the difference: Scripts: async, defer
Usually, if you do not solve the order of scripts loading using async or defer, then next option is to fall back to enclosing document loading apis such as document.onreadystatechange
or document.readyState
etc.,
1 Like
Hello @Santhosh
I have tried the solution you have provided and is giving the below error.
Please can we get on a quick call once.
system
(system)
Closed
April 19, 2023, 10:29am
9
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.