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
Please help
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!")
},
});
});
for odoo11: I need to change on_focus to onFocus (didn't try on odoo10)
odoo.define('snippet_testimonial_options', function(require) {
'use strict';
var options = require('web_editor.snippets.options');
options.registry.snippet_testimonial_options = options.Class.extend({
onFocus: function() {
alert("On focus!")
},
});
});
sombatsombat answer works for me. In odoo 12 onFocus
is used. List of events are given on this link.
Also first argument snippet_testimonial_options
is optional. we can simply ignore it.
odoo.define(function (require) {
var options = require('web_editor.snippets.options');
console.log(options);
options.registry.snippet_testimonial_options = options.Class.extend({
onFocus: function () {
alert("On focus!")
},
});
});