如何在鼠标移开时隐藏 primefaces 菜单栏

Gre*_*ory 0 javascript primefaces

我需要p:menubar躲起来mouseout。我怎样才能得到这个?尝试过覆盖PrimeFaces.widget.Menubar.prototype方法,但总是有东西被破坏。

Gre*_*ory 5

下一个解决方案对我有用。我启动计时器以在停用时隐藏所有内容,在激活和重新激活时清除它。

PrimeFaces.widget.Menubar.prototype.deactivate = function(b, a) {
       var menu = this;
       menu.activeitem = null;
       b.children("a.ui-menuitem-link").removeClass(
                    "ui-state-hover ui-state-active");
       b.removeClass("ui-menuitem-active ui-menuitem-highlight");
       if (a) {
             b.children("ul.ui-menu-child").fadeOut("fast");
       } else {
             b.children("ul.ui-menu-child").hide();
             if (!this.timer) {
                    this.timer = setTimeout(function() {
                           menu.reset();
                    }, 300);
             }
       }
}

PrimeFaces.widget.Menubar.prototype.reactivate = function(d) {
       if (this.timer) {
             clearTimeout(this.timer);
             this.timer = null;
       }
       this.activeitem = d;
       var c = d.children("ul.ui-menu-child"), b = c
                    .children("li.ui-menuitem-active:first"), a = this;
       if (b.length == 1) {
             a.deactivate(b)
       }
}

PrimeFaces.widget.Menubar.prototype.activate = function(b) {
       if (this.timer) {
             clearTimeout(this.timer);
             this.timer = null;
       }
       this.highlight(b);
       var a = b.children("ul.ui-menu-child");
       if (a.length == 1) {
             this.showSubmenu(b, a)
       }
}
Run Code Online (Sandbox Code Playgroud)