Resources
I am using royalSlider as a plugin. Here is a quick link to the documentation & API.
On my site the slider works as height: 100%; width: 100%
fullscreen slider.
Content Structure
The structure of my site is quite simple: I have slides that I use as cover, lets call them .cover
, each followed by a slide containing more information. Lets call them .sub
.
Content Cover Nr. 1
Subslide Content Nr. 1
Content Cover Nr. 2
Subslide Content Nr. 2
Content Cover Nr. 3
Subslide Content Nr. 3
Content Cover Nr. 4
Subslide Content Nr. 4
If it is easier to understand, you can check the live site right here.
Inside the function, which appends my sub slides, I create three buttons on the right side to scroll up, scroll down and close the current slide. Scrolling down works just fine. (Check my main.js file right here, line 177)
The Problem
The browser binds all buttons, selected using $(p.sl_button)
to the same sub slide, instead of binding each button to its own parent.
Hard to explain, easy to try. If you, for example:
- Open Subslide Number 5
- Open Subslide Number 2
- Scroll to Subslide Number 5
- Click on the Close Button (X with red background)
the system "breaks". Instead of closing the Subslide Number 5, it closes the subslide number 2 (which was the last time, the function named above got called.
How can I fix this problem?
The code I use to bind the buttons on my subslides:
// Append Slides by ID and Database
function appendIt(num_id) {
var $parid = num_id.parents('.rsContent').attr('id');
var $sub_id = sliderInstance.currSlideId + 1;
// get current slide id & increase by 1
// append html slide
sliderInstance.appendSlide(eval($parid), $sub_id);
sliderInstance.next();
// close button on sub slides
$('.scrolldown').on('click', function(){
sliderInstance.next();
});
// Scroll Slide Up
$('.scrollup').on('click', function(){
sliderInstance.prev();
});
// Close Subslide
$('.close').on('click', function(){
$('#'+$parid+' p.sl_button').addClass('in');
sliderInstance.prev();
setTimeout( function(){sliderInstance.removeSlide($sub_id);} , 600 );
});
};
If you need further information to recreate my bug feel free to ask. I appreciate any help or hinds regarding this topic. Thanks in advance to everyone digging into my problem.