Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
14554 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Autor Mejor respuesta

Thank you so much Dharmesh , that fixed my problem.

greetings.

Avatar
Descartar

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.

Publicaciones relacionadas Respuestas Vistas Actividad
3
feb 23
22004
0
ago 16
4444
0
sept 23
1770
0
sept 23
1491
1
jun 23
1858