0

Execute Javascript on component visible

asked 2013-01-16 07:26:52 +0800

batman256 gravatar image batman256
21

updated 2013-01-22 10:36:09 +0800

neillee gravatar image neillee flag of Taiwan
1692 1 5
https://plus.google.com/u...

Hi,

I would like to execute a javascript function every time a component becomes visible. I have tries zk.afterMount, but this only gets triggered once. When visibility of the component changes (in a tab switch) the function is not triggered when the tab is opned again. Is there some other hook to accomplish this?

B.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-01-22 10:09:02 +0800

neillee gravatar image neillee flag of Taiwan
1692 1 5
https://plus.google.com/u...

updated 2013-01-22 10:31:19 +0800

Please refer to Client-side Reference about responding to client-side activity. onShow is called after the widget becomes visible.

Below is a simple example that will alert each time the window becomes visible again.

<zk>
    <script defer="true">
        var oldWindow = zul.wnd.Window.prototype;
        zk.override(zul.wnd.Window.prototype, oldWindow, {
            onShow: function(ctl) {
                alert('Window becomes visible');
            }
        });
    </script>
    <tabbox>
        <tabs>
            <tab>Tab 1</tab>
            <tab>Tab 2</tab>
        </tabs>
        <tabpanels>
            <tabpanel>
                <window title="test" border="normal">
                    Main Window
                </window>
            </tabpanel>
            <tabpanel>
            </tabpanel>
        </tabpanels>
    </tabbox>
</zk>
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2013-01-16 07:26:52 +0800

Seen: 49 times

Last updated: Jan 22 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More