Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
14632 Visninger

I'm reading about themes in odoo 9, but in the part about javascript options i have a problem, I copied and paste this code

(function() {
    'use strict';
    var website = openerp.website;
    website.openerp_website = {};

    website.snippet.options.snippet_testimonial_options = website.snippet.Option.extend({
        on_focus: function() {
            alert("On focus!");
        }
    })
})();


then I follwed the instructions but I didn't get the alert whit the message "on focus!" so Ichecked the web console and I found this message 

Uncaught ReferenceError: openerp is not defined

    at website.assets_frontend.js:846

    at website.assets_frontend.js:846

I was looking for but I didn'y find anything. 

if someone have the answer, please tell me.

Thank you so much!


Avatar
Kassér
Bedste svar

Hello Carlos

Your Problem

=============

  •  right now you are using old js (odoo-8 js).


    //OLD js(Odoo-8 snippets structure)
    (function() { 'use strict'; var website = openerp.website; website.openerp_website = {}; website.snippet.options.snippet_testimonial_options = website.snippet.Option.extend({ on_focus: function() { alert("On focus!"); } }) })();

  •       So you need to use new snippets js structure that i mention below. 

Solution
=============

follow odoo9 snippets js structure like below code, 

odoo.define('website.snippets.editor', function (require) {
    'use strict';
   
    var options = require('web_editor.snippets.options');
    var snippet_editor = require('web_editor.snippet.editor');
   
    options.registry.snippet_testimonial_options = options.registry.Class.extend({
        on_focus: function() {
            alert("On focus!");
        },
    });
});


I hope my answer is helpful.

If any query so comment please.

Avatar
Kassér
Forfatter Bedste svar

Thank you so much Dharmesh , that fixed my problem.

greetings.

Avatar
Kassér

Your welcome carlos and if you fixed your problem by this solution then just tick this answer as a correct one, so other can also get the help from this solution.

Related Posts Besvarelser Visninger Aktivitet
3
feb. 23
22107
0
aug. 16
4495
0
sep. 23
1851
0
sep. 23
1547
1
jun. 23
1935