跳至內容
選單
此問題已被標幟
1 回覆
1094 瀏覽次數

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.

頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
11月 24
1336
5
8月 25
9766
2
7月 25
934
4
6月 25
1050
1
6月 25
1349