views:

25

answers:

1
+1  Q: 

Jquery Plugin Help

I'm using this plugin:

http://www.jeremymartin.name/projects.php?project=kwicks

And my code follows this example:

http://www.jeremymartin.name/examples/kwicks.php?example=7

I'm using the configuration setting of: sticky: true,

The plugin sets the first element in the list to be active and expands to display the content that hidden for all other elements.

What I want to be able to do is dictate which element is 'active' rather than it always being the first element?

I've tried adding .active into the markup but obviously the JS adds .active for me to the first element.

+1  A: 

There's a configuration directive called defaultKwick which controls which slide will be open by default. It's zero-indexed, so defaultKwick: 0 would make the first element visible, defaultKwick: 1 the second and so on.

If you want to do this dynamically based on an element which has the class active, you can do something like this:

$('#kwicks').kwicks({
    sticky: true,
    defaultKwick: $('#kwicks .active').prevAll().size()
});

That would make whichever element has the class active open by default.

Tatu Ulmanen