Search and Top Navigation
#4673 closed enhancement (fixed)
Opened July 12, 2009 08:29PM UTC
Closed August 11, 2009 01:52AM UTC
Last modified October 11, 2012 09:15PM UTC
Method to find current active item
Reported by: | wichert | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | ui.accordion | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
It would be nice to have a method to find out what the index number of current active item is. An example use for this is to programatically activate the next or previous item.
Attachments (0)
Change History (5)
Changed July 12, 2009 08:48PM UTC by comment:1
Changed August 01, 2009 03:17PM UTC by comment:2
Replying to [comment:1 wichert]:
As a workaround you can use this bit of code:> var accordion = $(".accordion"); > var items = $.map(accordion.find("dt"), > function(a) { return $(a).hasClass("ui-state-active"); }); > var active = $.inArray(true, items); >
If you place this code in the following way, it always produces -1:
$("#accordion").accordion({
header: "h3",
fillSpace: true,
change: function(event, ui) {
var accordion = $(".accordion");
var items = $.map(accordion.find("dt"),
function(a) { return $(a).hasClass("ui-state-active"); });
var active = $.inArray(true, items);
alert(active);
}
});
The JQuery should not only make "active" work, but the documentation should be clearer about what properties are set up for
ui.newHeader jQuery object, activated header
ui.oldHeader jQuery object, previous header
ui.newContent jQuery object, activated content
ui.oldContent jQuery object, previous content
Changed August 01, 2009 04:16PM UTC by comment:3
In fact the very simplest workround is to add a unique class to each header with click( fn ) (or hover event) attached to it. That will enable a value to be assigned to a variable or initiate an action.
Changed August 11, 2009 01:52AM UTC by comment:4
resolution: | → fixed |
---|---|
status: | new → closed |
Fixed in r3044
Changed October 11, 2012 09:15PM UTC by comment:5
milestone: | TBD |
---|
Milestone TBD deleted
As a workaround you can use this bit of code: