diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 8873703d790..e0cf880e611 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -54,39 +54,36 @@ website.TopBar.include({ website.TopBarCustomize = Widget.extend({ events: { - 'mousedown a.dropdown-toggle': 'load_menu', - 'click ul a[data-view-id]': 'do_customize', + 'click > ul a[data-view-id]': 'do_customize', }, start: function () { - var self = this; - this.$menu = self.$el.find('ul'); this.view_name = $(document.documentElement).data('view-xmlid'); if (!this.view_name) { this.$el.hide(); } - this.loaded = false; + + if (this.$el.is(".open")) { + this.load_menu(); + } else { + this.$el.one("mousedown", "> a.dropdown-toggle", this.load_menu.bind(this)); + } }, load_menu: function () { - var self = this; - if(this.loaded) { - return; - } + var $menu = this.$el.children("ul"); ajax.jsonRpc('/website/customize_template_get', 'call', { key: this.view_name, }).then(function (result) { _.each(result, function (item) { - if (item.key === "website.debugger" && !window.location.search.match(/[&?]debug(&|$)/)) return; if (item.header) { - self.$menu.append('