Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Workaround I found for my problem:</p> <pre><code>// 1. Read and save old carousel navigation text (like "Prev" and "Next") carouselprevoldtext = $('#ui-carousel-prev').children(".carousel-control-text").html(); carouselnextoldtext = $('#ui-carousel-next').children(".carousel-control-text").html(); // 2. How many slides? maxslidenumber = $(".carousel-slide").length; // 3. Create an array with all slides' IDs (in this particular case I use parent() as ID is assigned through CMS by user not hardcoded - and extra DIV is added by CMS) slideidarray = {}; $(".carousel-slide").each( function(index){ slideidarray[index] = $ ( this ).parent().attr('id'); } ); // 4. Run the carousel $( ".carousel-wrapper" ).rcarousel({ OPTIONS HERE }); // 5. Find current slide currentslide = $( ".carousel-wrapper" ).rcarousel( "getCurrentPage" ); // starts from 1 not from 0 // 6. Find previous and next slides ID texts // A. For first slide - previous slide is the last one if (currentslide == 1) { prevslideidtext = slideidarray[maxslidenumber - 1]; nextslideidtext = slideidarray[1]; } else { prevslideidtext = slideidarray[currentslide - 2]; // as arrays count from 0 nextslideidtext = slideidarray[currentslide]; // B. For last slide - next slide is the first one if (currentslide == maxslidenumber) { nextslideidtext = slideidarray[0]; } } // 7. Create new carousel navigation text carouselprevupdhtml = "&lt;span class='carousel-control-text'&gt;" + carouselprevoldtext + ": &lt;/span&gt;&lt;span class='carousel-control-title'&gt;" + prevslideidtext + '&lt;/span&gt;'; carouselnextupdhtml = "&lt;span class='carousel-control-text'&gt;" + carouselnextoldtext + ": &lt;/span&gt;&lt;span class='carousel-control-title'&gt;" + nextslideidtext + '&lt;/span&gt;'; // 8. Assign it to carousel navigation $('#ui-carousel-prev').html( carouselprevupdhtml ); $('#ui-carousel-next').html( carouselnextupdhtml ); </code></pre> <p>Of course steps 5 to 8 needs to be repeated each time when slide is changed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload