Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
1068 Visualizações

Hello,

I am encountering an issue in Odoo 18 while working with JavaScript files for a website theme. Specifically, the plugins are throwing errors such as 'x' is not defined and similar issues.

Although jQuery (version 3.6.3) is included in the web module/package and is loaded by default in the web.assets_frontend bundle, the errors persist even when using plugins compatible with this version of jQuery.

NOTE : To clarify, I am using the plugins exactly as provided by the CDN, without any modifications to their code.

Here are the approaches I have tried in the web.assets_frontend bundle within the __manifest__.py file:

  1. Attempted to load the assets without explicitly including jQuery, as the required plugins are already compatible with version 3.6.3.
  2. Used a direct CDN link for jQuery.
  3. Provided a local path to jQuery in the asset declaration.


My primary goal is to implement animated snippets on the website. However, despite trying the above approaches, I have been unable to resolve the issue.

I would greatly appreciate any insights or solutions to overcome this challenge.

Avatar
Cancelar
Melhor resposta

Hello Mohammed Salman Uddin,


I hope you are doing well.


To resolve the issue, I recommend the following approach:

- Import loadJS from Odoo's core assets in the JavaScript file where you wish to implement the feature:

import { loadJS } from "@web/core/assets";

- Then, use loadJS(url) to load the JavaScript file from the URL:

loadJS(url);


- This method helps avoid any potential jQuery issues and prevents script conflicts.

- It ensures a smooth and efficient loading process for external JavaScript files in Odoo.

- Make sure to check the compatibility of the external JavaScript with your Odoo version.


I Hope this information proves helpful to you.


Thanks & Regards,

Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
0
nov. 24
1327
5
ago. 25
9740
2
jul. 25
905
4
jun. 25
1022
1
jun. 25
1336