Multiple instances of the Mega Slider D8

clazogosa's picture
clazogosa
Thu, 08/09/2018 - 20:50
#1
Multiple instances of the Mega Slider D8
When I place 2 instances of the Mega Slider in the same page, it only shows me the first.
cindy's picture
cindy
Fri, 08/10/2018 - 00:51

Hello,

Because those sliders share the same ID, so only the first slider displays. You can follow one of the two solutions below:
Solution 1:
In page admin/structure/md-slider, please clone slider. Then there is another block slider and you can assign to any region. Then, your sliders will have different ID and they can all be shown

Solution 2: Open file md_slider/assets/js/frontend/init-md-slider.js and replace:

$.each(drupalSettings.md_slider, function(slid, slider) {
listMegaSlide[i] = $('#md-slider-' + slid + '-block').mdSlider(slider);
if(slider.device_enable){
cssInline += '@media (max-width: ' + slider.device_width + 'px) {\
#md-slider-' + slid + '-block .md-objects {\
display: none;\
}\
} ';
}

if(slider.device_width){
cssInline += '@media (max-width: ' + slider.device_width + 'px) {\
.hideonmobile {\
display: none !important;\
}\
}';
}

i++;
});

with:

$('.md-slide-items').each(function(){
var slid = $(this).attr('id').split('-')[2],
slider = drupalSettings.md_slider[slid];
listMegaSlide[i] = $(this).mdSlider(slider);
if(slider.device_enable){
cssInline += '@media (max-width: ' + slider.device_width + 'px) {\
#md-slider-' + slid + '-block .md-objects {\
display: none;\
}\
} ';
}

if(slider.device_width){
cssInline += '@media (max-width: ' + slider.device_width + 'px) {\
.hideonmobile {\
display: none !important;\
}\
}';
}

i++;
});

clazogosa's picture
clazogosa
Fri, 08/10/2018 - 12:06

  

Hello this does not work, I have 2 regions each with a different slider block and it only shows me the first

clazogosa's picture
clazogosa
Fri, 08/10/2018 - 12:13

I tried your second opcion

cindy's picture
cindy
Sun, 08/12/2018 - 22:48

Hello,

Did you clear Drupal cache?

Please send us your site url and admin account to check this issue

Log in or register to post comments
Have More Idea?

We are here to build your website!

No Universal solution fits all special business requirements. Our experienced team is ready with ideas and state-of-the-art technical solutions to consult the best solution within your budget.