Resetting the Index Indicator

ATLANTIQ's Avatar

ATLANTIQ

23 Nov, 2012 02:43 PM

I'm using this script:
http://help.dimsemenov.com/kb/royalslider-javascript-api/creating-s...
in order to display a varying number of content boxes drawn from a database with PHP. The site also runs on jQuery Mobile.
The script, along with RoyalSider, works great, and when I press a button/link in the boxes that loads the current page again (but adds a few variables to the URL needed for some PHP GET commands).

However, as the page is reloaded, the index indicator stops working properly. The previous counter is stuck (for example if I press the button in the 5th box out of 12, the counter gets stuck at "5 of 12" and no longer updates properly.
I am guessing that to fix it, I need to reset the Index Indicator somehow, or maybe I installed the Javascript above improperly (I am still a novice with JavaScript)

The Javascript initialised right after the royalslider looks like this:

<script type="text/javascript">
    jQuery(document).ready(function($) {
      var sliderJQ = $(".page-weindetail-empfohlen .royalSlider").royalSlider({
            autoHeight: false,
            fadeinLoadedSlide: false,
            controlNavigationSpacing: 0,
            controlNavigation: 'none',
            imageScaleMode: 'none',
            imageAlignCenter:false,
            loop: false,
            loopRewind: true,
            numImagesToPreload: 6,
            keyboardNavEnabled: true,
            arrowsNav: false,
            arrowsNavAutohide: false,
            arrowsNavHideOnTouch: false
          });
      var sliderInstance = sliderJQ.data('royalSlider');
      
      var slideCountEl = $('<div class="rsSlideCount"></div>').appendTo( sliderJQ );
      
       function updCount() {
             slideCountEl.html( (sliderInstance.currSlideId+1) + ' / ' + sliderInstance.numSlides );
         }
         sliderInstance.ev.on('rsAfterSlideChange', updCount);
         updCount();
    });  
</script>
  1. Support Staff 1 Posted by Dmytro Semenov on 23 Nov, 2012 09:18 PM

    Dmytro Semenov's Avatar

    Hi,

    Please make sure that this code runs only once. Or send me a link to your page and I'll take a look what's wrong.

    Dmitry

  2. 2 Posted by ATLANTIQ on 03 Dec, 2012 03:42 PM

    ATLANTIQ's Avatar

    Thanks for the quick response.
    I fixed this issue by loading a new instance of the code each time the page is loaded by inserting a GET variable into the URL that decides between the code and a copied version of the code. The copies are the same, only the class is different.

    This might not be the most ideal solution, but it works flawlessly for me. Thanks for giving me the idea, though.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac