gilbitron/Nivo-Slider — Issue #245: Caption class is not applied
Author: closedbracket
Created: 2011-12-06 03:32:53+00:00
State: open

In order to have a different style for each HTML caption, we added a second class to the 'nivo-html-caption', like this:

```

The New Bowl Concept

```

However, It outputs the following code:

```

The New Bowl Concept

```

Notice the `title_bottom` class is missing.

To get around this, we added these lines to the processCaption function before the caption fades in (line 106):

```
position_class = $($('.nivo-html-caption')[$('.nivo-controlNav').find('.active').index()]).attr('class').split(' ')[1];
$('.nivo-caption').attr('class', "nivo-caption " + position_class);
```

The first line finds the active image position. It then uses that position to find the corresponding caption. It sets a `position_class` variable equal to the second class of that caption div (in our case 'title_bottom')

The second line adds that class to the caption element the Nivo Slider creates.

Note: This works when the slider image changes. However, for it to work when the slider first loads, you need to include the same code above in the `afterLoad` option.