Search code examples
odoo-10

odoo 10 how to create Snippets Javascript option


I'm trying to Create Snippets in odoo 10 according to https://www.odoo.com/documentation/10.0/howtos/themes.html#create-snippets

I created the snippets and add the js option, the code from the example

(function() {
    'use strict';
    var website = odoo.website;
    website.odoo_website = {};

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

fails since odoo.website is not defined see

enter image description here

Please help


Solution

  • here is the correct code for /theme_tst/static/src/js/tutorial_editor.js

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