Opened 10 years ago

Closed 9 years ago

#4959 closed bug (fixed)

accordion navigation failed to find header from a deeply located element

Reported by: hoball Owned by:
Priority: minor Milestone: 1.8.2
Component: ui.accordion Version: 1.7.2
Keywords: navigation, parent, level Cc:
Blocked by: Blocking:

Description

Currently the code for the option "navigation" inside ui.accordion.js is:

if ( o.navigation ) {
	var current = this.element.find("a").filter(o.navigationFilter);
	if ( current.length ) {
		if ( current.filter(o.header).length ) {
			this.active = current;
		} else {
			this.active = current.parent().parent().prev();
			current.addClass("ui-accordion-content-active");
		}
	}
}

This block of code is fixed to search 2 levels up for the header.

In my navigation menu, I am using more than 2 levels and this results a failure to make "navigation: true" works.

I have to manually fix it by adding one more parent(). Perhaps we may use the parents() method to make it more flexible.

$(document).ready(function() {
    $("#accordion").accordion({
        active: false,
        header: 'h3',
        collapsible: true,
        navigation: true
    });

});
<div id="accordion"><!-- START ACCORDION -->

    <h3><a href="#">Header</a></h3>
    <div>
        <h4>Subheader A</h4>
        <ul>
            <li><a href="sub-a-1.html">Link SubA 1</a><</li>
            <li><a href="sub-a-2.html">Link SubA 2</a><</li>
        </ul>

        <h4>Subheader B</h4>
        <ul>
            <li><a href="sub-b-1.html">Link SubB 1</a><</li>
            <li><a href="sub-b-2.html">Link SubB 1</a><</li>
        </ul>
    </div>

    <!-- // more main headers -->
    <h3></h3>
    <div></div>
</div><!-- END ACCORDION -->

Change History (2)

comment:1 Changed 10 years ago by Jörn Zaefferer

Milestone: TBD1.8

comment:2 Changed 9 years ago by Scott González

Milestone: 1.91.8.2
Resolution: fixed
Status: newclosed

This was fixed in a previous release. We now use .closest() instead of .parent().parent().

Note: See TracTickets for help on using tickets.