user1122857
user1122857

Reputation:

How to get Position of Popup in ZK?

I have opened an Popup, now I want to know it's position is there any getXXX() for it, if no then how can I get the posotion of the Popup.

Upvotes: 0

Views: 1731

Answers (1)

benbai123
benbai123

Reputation: 1463

Try this

<zk>
<script type="text/javascript">
    function updatePos(id) {
        var $pp = jq('$any'),
            left = zk.Widget.$(jq('$left')[0]),
            top = zk.Widget.$(jq('$top')[0]);

        // set client side value
        left.setValue($pp.offset().left + '');
        top.setValue($pp.offset().top + '');
        // trigger onChange to update server side
        left.fireOnChange();
        top.fireOnChange();
    }
</script>
<separator bar="true" />
<label value="Tooptip for Another Popup" tooltip="any" />
<popup id="any" width="300px">
    <attribute name="onOpen">
        if (event.isOpen())
            Clients.evalJavaScript("updatePos();")
    </attribute>
    <vbox>
        ZK simply rich.
        <toolbarbutton label="ZK your killer Web application now!"
            href="http://www.zkoss.org" />
    </vbox>
</popup>
<textbox id="left" />
<textbox id="top" />
<button onClick='alert(left.getValue() + ", " + top.getValue());' label="show left and top" />
</zk>

References: ZK Popup ZK Client Side Programming

Upvotes: 1

Related Questions