找到你要的答案

Q:Primefaces header click toggle

Q:primefaces标题点击切换

I have two panels in panel header to click i want toggle panel.

<script>
$(document).on("click", ".ui-panel:has(.ui-panel-titlebar-icon) .ui-panel-titlebar", function(e) {
    console.log("click:");
PF("widgetVar").toggle();//Need to know how given widgetVar

});
</script>

<p:panel id="userPanel1" widgetVar="org1"  toggleable="true" collapsed="true">
.....
</p:panel>

<p:panel id="userPanel2" widgetVar="org2"  toggleable="true" collapsed="true">
.....
</p:panel>

my doubt panel header to click send widgetVar and Toggle current panel.That is PF("widgetVar").toggle() to set pass current panel widgetVar on header click event and In same to I use PF("widgetVar").collapse() panel.

我有两个面板面板面板点击我要切换面板。

<script>
$(document).on("click", ".ui-panel:has(.ui-panel-titlebar-icon) .ui-panel-titlebar", function(e) {
    console.log("click:");
PF("widgetVar").toggle();//Need to know how given widgetVar

});
</script>

<p:panel id="userPanel1" widgetVar="org1"  toggleable="true" collapsed="true">
.....
</p:panel>

<p:panel id="userPanel2" widgetVar="org2"  toggleable="true" collapsed="true">
.....
</p:panel>

我怀疑面板标题点击发送widgetvar和切换面板,PF(“widgetvar”)。toggle()设置通电流面板widgetvar标题单击事件和同我用PF(“widgetvar”)。collapse()面板。

answer1: 回答1:

In the primefaces showcase there are examples:

    <p:panel id="toggleable" header="Toggleable" toggleable="true" closable="true" toggleSpeed="500" closeSpeed="500" widgetVar="panel" style="margin-bottom:20px">
        <f:facet name="options">
            <p:menu>
                <p:submenu label="Settings">
                    <p:menuitem value="Toggle" url="#" icon="ui-icon-newwin" onclick="PF('panel').toggle();" />
                </p:submenu>
            </p:menu>
        </f:facet>
    </p:panel>

Just change:

PF('panel').toggle(); to PF('panel').toggle();PF('panel').collapse(); and remove that script (unless you want to log a click lol). You can add as many function as you like in the onclick attribute and you can even do this like this: onclick="alert('hi');". That is useful for debugging sometimes.

If that wasn't what you were asking for please edit your post. If it was you can accept my answer by clicking the v under the score to show your gratitude and to give me free karma!

Cheers.

在primefaces展示有例子:

    <p:panel id="toggleable" header="Toggleable" toggleable="true" closable="true" toggleSpeed="500" closeSpeed="500" widgetVar="panel" style="margin-bottom:20px">
        <f:facet name="options">
            <p:menu>
                <p:submenu label="Settings">
                    <p:menuitem value="Toggle" url="#" icon="ui-icon-newwin" onclick="PF('panel').toggle();" />
                </p:submenu>
            </p:menu>
        </f:facet>
    </p:panel>

只是改变:

PF('panel”)。toggle();PF('panel”)。toggle();PF('panel”)。collapse();和删除脚本(除非你想记录一下哈哈)。您可以添加许多功能如你喜欢在onclick属性,你甚至可以做到这样:onclick=“警报('嗨');”。这是有用的调试有时。

如果这不是你所要求的,请编辑你的帖子。如果是你可以接受我的答案,点击V的分数显示你的感激,给我自由的因缘!

干杯.

jquery  jsf  primefaces