-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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.
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
Asked: 2019-09-02 10:49:23 +0800
Seen: 10 times
Last updated: Sep 02 '19