This question has been flagged
2 Replies
6072 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



Avatar
Discard

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

Author Best Answer

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.


Avatar
Discard