Prevent the tab page from repeatedly sending requests to the server, and the tab page repeatedly requests to the server

Source: Internet
Author: User

Prevent the tab page from repeatedly sending requests to the server, and the tab page repeatedly requests to the server

Let's look at the figure.

On the left is the enterprise tree, and on the right is a tab page based on enterprise changes.

Features: 1. We hope that if the selected enterprise remains unchanged, we will request the server when switching the five tabs next to it. The following switch back and forth tab page does not request the server side (the premise is that the enterprise tree does not switch ).

2. If the selected enterprise changes, the table structure on the right also changes accordingly.


Train of Thought. 1. When the enterprise tree is not switched, each time we click a tab, we will give it an identifier to determine that if the enterprise tree remains unchanged and switches back and forth, we will not request the server. As follows:

$ ("# Tab-director"). click (function (){
Var treeId = getSelectedTreeId ();
If (undefined = treeId | "root" = treeId)
Return false;
_ Tab = 1;
If (_ isDirLoad = false ){
_ IsDirLoad = true; // The identifier here.

}

});


2 .. When switching the enterprise tree, we need to change the previous _ isDirLoad = true to false.

For example, function zTreeOnClick (event, treeId, treeNode ){
Var treeId = getSelectedTreeId (); // The treeId is the uuid of the selected enterprise.
If (treeId = "root "){
Return;
}
_ IsCommLoad = false;


Based on the ideas of 1 and 2, we can implement the functions required above.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.