How To Stay In The Same Tab In Cjuitabs After Action

Helleo folks,

I would like to know how to do to go back to the previous tab when I’m using CJuiTabs.

I have a table with many tabs, and when I perform an action in one of them (add, delete, update…) it always comeback to the very first tabs.

For eg when Im in tab 3, after refreshing, I want it to stay in the same tab and not go to the first tab in the table.

Thank you for your help

please any help or suggestion would be much appreciated thank you

I would use ajax. That way you can refresh only certain CJuiTabs with the server response - without refreshing the whole view (all CJuiTabs).

thank you for the reply

can you please show me how can I do it

Hi boot_strap

Unfortunately I cannot give you a complete explanation because it is lengthy and depends on the design of your views.

  1. If you have a single activeForm which is distributed over the various CJuiTabs, then you will probably have to refresh the whole view with all tabs.

  2. But if you have individual views in each CJuiTabs then you can give the outside div of each view a unique id. Then you can update the content of that div with the ajax response.

  3. If you have CGridViews in the different CJuiTabs, then it becomes a different monster, because the javascript of the CGridView will be added to the javascript of the other views - causing multiple submits and other problems. To prevent this, I put the CGridView in an iframe inside the CJuiTab. In this case I do not update the CGridview with the ajax response, but rather reload the iframe source with the CGridview’s url.

This prevents javascript problems, but it brings new challenges if you want to communicate from views "inside" the iframe to views "outside" the iframe.

Also, you would probably want to receive "array like" data from the server as ajax response, because then you can include flags in the response to inform your ajax function about the status of the transaction. If this is the case then you have to use "json" as the ajax data type.

Hope it gives you some ideas.