Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to extend website.editor.Dialog in frontend

By
Evans Bernier
on 6/20/16, 4:10 PM 385 views

Hello,

I would like to add a popup dialog on frontend on button click. Something like option "Edit Menu" in website editor. When we click on it, a popup dialog appear and let us organize website menu. I saw that this functionality extend the website.editor.Dialog in JS like that:

    website.contentMenu.EditMenuDialog = website.editor.Dialog.extend({
        template: 'website.contentMenu.dialog.edit',
events: _.extend({}, website.editor.Dialog.prototype.events, {
'click a.js_add_menu': 'add_menu',
'click button.js_edit_menu': 'edit_menu',
'click button.js_delete_menu': 'delete_menu',
}),

This code is available in /server/addons/website/static/src/js/website.contentMenu.js

I tried to extend website.editor.Dialog in my custom module to use the default popup dialog form, but I get this error when my page is loaded:

TypeError: website.editor is undefined

This is a part of my code:

    website.manageVideo.Dialog = website.editor.Dialog.extend({
template: 'custom_moduloe.manageVideo.dialog.edit',
events: _.extend({}, website.editor.Dialog.prototype.events, {
'click a.js_add_video': 'add_video',
'click button.js_edit_video': 'edit_video',
'click button.js_delete_video': 'delete_video',
}),
....

website.ready().done(function() {
var content = new website.manageVideo.Dialog();
content.setElement($('.oe_content_video'));
content.start();
});
 

My templates are created and it should be working.

So, how can I create a popup dialog?

Thanks



please provide your js file... have you added var website = require('website.website'); ?

Jérémy Kersten (jke)
on 6/20/16, 7:36 PM
0
Evans Bernier
On 6/20/16, 8:25 PM

I am using Odoo8. I added "var website = openerp.website;" on the top of my function. I think that "var website = require('website.website'); is for odoo 9.

This is the my JS file :

https://mensuel.framapad.org/p/QIX4qmb2Co

This is almost identical of JS function of "edit menu" from Odoo. I tried to use this code as a base.


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/20/16, 4:10 PM
Seen: 385 times
Last updated: 6/20/16, 8:25 PM