David Leedy
David Leedy

Reputation: 3593

How do you you add an onClick event to <xp:panel>

I'd like to make a Panel "clickable" and run SSJS code. Previously when I've done this I've added a table 1-cell 1-row to the panel since that has an onClick event. Is there a way to do it on the Panel itself?

Also - If there is a way to put onClick on a Panel, if that Panel contains a link, I assume that link would be "Above" the panel itself and be independentally clickable.... right?

Upvotes: 1

Views: 1472

Answers (1)

Per Henrik Lausten
Per Henrik Lausten

Reputation: 21709

Just add an onClick event to the panel. Here is some example code that redirects to "anotherpage" when the panel is clicked:

<xp:panel id="test">
    Click me
    <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
        <xp:this.action><![CDATA[#{javascript:context.redirectToPage("anotherpage.xsp")}]]></xp:this.action>
    </xp:eventHandler>
</xp:panel>

If you add a link to the panel, the link is "above" the panel:

<xp:panel id="test">
    Click me!
    <xp:link escape="true" text="and me!" id="link1">
        <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
            <xp:this.action><![CDATA[#{javascript:context.redirectToPage("page.xsp")}]]></xp:this.action>
        </xp:eventHandler>
    </xp:link>

    <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
        <xp:this.action><![CDATA[#{javascript:context.redirectToPage("window.xsp")}]]></xp:this.action>
    </xp:eventHandler>
</xp:panel>

Upvotes: 5

Related Questions