跳至內容
選單
此問題已被標幟
1 回覆
9110 瀏覽次數
This is my custom page in dpsir module


xml version="1.0" encoding="utf-8"?><odoo><templateid="custom_page"name="custom page">        <tt-call="website.layout">        <scripttype="text/javascript"src="/dpsir/static/src/js/custom.js">script>            t>template>odoo>


and this is custom js file

odoo.define('dpsir.custom', function (require) {    // Your code here});

I'm getting uncaught reference error odoo is not defined

頭像
捨棄
作者

what if I want to use the javascript file for frontend website, like handling button click, adding or removing class of an html element useing jquery etc.?

最佳答案

Hi


add your javascript file under module_name -> static -> src-> js folder.

you can code as like following 

odoo.define('module_name.models', function (require) {

});

and you can load the js file in the manifest

'assets': {
'web.assets_frontend': [
'module_name/static/src/js/file_name.js’]
}

check this references for js file

https://www.odoo.com/documentation/16.0/developer/reference/frontend/javascript_modules.html


Hope this Helps

Regards

頭像
捨棄

Can you also share that how you can add custom js file in your template

相關帖文 回覆 瀏覽次數 活動
0
7月 25
812
1
7月 25
5934
0
7月 25
1606
0
6月 25
1563
1
6月 25
1484