Catch a tabbox before it switches tabs?

asked 2019-09-02 10:49:23 +0800

xuesong gravatar image xuesong
101 2

Is it possible to have an event that will execute PRIOR to the tabbox switching tabs?

I have a situation where I need to intercept the tabbox when the user clicks on another tab to check whether the data on the current tab has been saved correctly BEFORE moving to the new tab.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-09-02 17:36:04 +0800

MDuchemin gravatar image MDuchemin
1891 1 5
ZK Team

Hi Xuesong,

The main principles to keep in mind is the order of events: - User clicks on the tab - Client side does 2 things: -- Client side selects the tab directly in the browser -- Client side sends a select event to the server then - Server receive onSelect and does updates - Updates are sent back to the client

It's fine to update the state of the tabbox "onSelect" in Java code, but you will have a small flickering effect where the client goes to the tab, and back to the original tab after the server sends the reply.

The cleaner, but slightly more complicated alternative is to prevent the user click from triggering selection on client side, whilst still sending a custom event to the server so that you can exploit that user click in a workflow.

There's a demo that show how to prevent tab selection by removing the client-side click event and replacing it by a custom event in MVC. demo here That one is written for MVC, so if you are going for a MVVM page, you would need to do a few adjustments like so: mvvm sample

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

1 follower



Asked: 2019-09-02 10:49:23 +0800

Seen: 9 times

Last updated: Sep 02 '19

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