First of all, jQuery selector is really powerful!
I encountered such a problem with easyui in the project
As shown in the picture, the current page displays the "Original Message Query" page, but the left navigation bar was selected at that time. It is "resend message query". How to link the menu on the right and the navigation on the left: click "Original Message Query" on the left, then expand "Reissue Arrival Message" on the right, and select "Original Message Query", "Backstage" Manage" off?
The implementation method is as follows:
1. The "original message query" on the right uses easyui's tabs control. Check the API to know that tabs has an onSelect method. As long as it is in onSelect Just write what you want to do in the method.
2. The trigger event has been found, so how to achieve the desired effect?
The code result of the left navigation bar is as shown above: the outermost layer is easyui's accordion control. There are many panels in the accordion. One panel corresponds to a parent directory in Figure 1 and the subdirectories below it. For example, the module "Reissue Arrival Report". There are two divs in the panel.
The first div is the parent directory, and the second div contains many subdirectories.
First, when the tabs on the right are selected, the corresponding navigation bar on the left is selected. First remove the selected status of all subdirectories, and then let the current subdirectory be selected.
$('#idaccordion li div').removeClass( "selected");
$('#idaccordion span:contains("' title '")').parent().parent().addClass("selected");
3. The problem is that the item that should be selected is selected, but the parent menu of the selected submenu is not expanded. Panel in easyui has an expand method, but how to know which panel (parent menu) should be expanded? As shown in Figure 2: "Original message query" has been selected, and now the parent menu of the reissue arrival report needs to be expanded. The first child node of the sibling node of the ancestor node of the element span where the "original message query" is located is the node where the "replacement arrival report" is located.
if( $('#idaccordion span:contains(" ' title '")').length > 0 ){
var accordionTitle = $('#idaccordion span:contains("' title '")').closest('.panel-body').prev( ).find('.panel-title').text();
var p = $('#idaccordion').accordion('getPanel',accordionTitle);
p.panel('expand') ;
}
First, search the span containing the text title in the descendant node with id idaccordion (i.e.
Original message query< ;/span>), then find the nearest ancestor node with class panel-body, and then find the previous sibling node of this node (i.e.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn