i have read and experimented on both of these:
How to output current slide number in Bootstrap 3 Carousel?
How to Get total and Current Slide Number of Carousel
The thing is have 3 (maybe more later) carousels within modals on the same page and that seems to drive bonkers both of the solutions linked above.
What i'm trying to do and i haven't been able to resolve is:
How do i display the actual slide number as (photo X of total Y) in the title of the modal keeping in mind i have many carousels in the same page.
For example I can't use
$('div.active').index() + 1;
because it always counts the slide number of the first carousel (and it seems to me wasteful since i have to have many copies of the same code for many carousels)
my code constructed from the answers above is:
// Slide number for #carousel1 in class .numslide1 (total counted by itemcar1)
var totalItems = $('.itemcar1').length;
var currentIndex = $('div.active').index() + 1;
$('.numslide1').html('FOTO '+currentIndex+' DE '+totalItems+'');
$('#carousel1').carousel({
interval: 5000
});
$('#carousel1').bind('slid', function() {
currentIndex = $('div.active').index() + 1;
$('.numslide1').html('FOTO '+currentIndex+' DE '+totalItems+'');
});
Thanks in advance!