Carousel activates Accordian?
Forum rules
IMPORTANT NOTE!!
DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.
PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
IMPORTANT NOTE!!
DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.
PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
-
Beth
-

- Posts: 128
- Joined: Mon Jan 15, 2018 10:55 pm
Carousel activates Accordian?
I know how to make carousel no.1 open slides on carousel no.2 using events and javascript like this: "$('#indexCarousel2').bootstrapcarousel(1)" - but can I do the same to make carousel no.1 trigger opening a panel on an accordian ?
I can do this by using shapes, too, but how about an accordian panel as the target to be opened?
Any help is appreciated.
I can do this by using shapes, too, but how about an accordian panel as the target to be opened?
Any help is appreciated.
- Pablo
- Posts: 24689
- Joined: Sun Mar 28, 2004 12:00 pm
- Location: Europe
- Contact:
Re: Carousel activates Accordian?
It depends on which accordion options you have selected.
jQuery UI has an 'active' method:
https://api.jqueryui.com/accordion/
For Bootstrap, you can use collapse
https://getbootstrap.com/docs/5.3/components/collapse/
For example:
bootstrap.Collapse.getOrCreateInstance('#Accordion1-collapse3').toggle();
jQuery UI has an 'active' method:
https://api.jqueryui.com/accordion/
For Bootstrap, you can use collapse
https://getbootstrap.com/docs/5.3/components/collapse/
For example:
bootstrap.Collapse.getOrCreateInstance('#Accordion1-collapse3').toggle();
-
Beth
-

- Posts: 128
- Joined: Mon Jan 15, 2018 10:55 pm
Re: Carousel activates Accordian?
Thank you for your quick answer Pablo. I'm afraid that this is over my head. I was hoping for something simple but that's OK. Just an idea...
- BaconFries
-

- Posts: 6301
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Carousel activates Accordian?
Maybe the following will do what you need. You will need to change carousel1 and Accordion1-collapse1 to your own requirements. To use simply.place using Page HTML Between the <head></head> tags* Note untested
Code: Select all
<script>
document.addEventListener('DOMContentLoaded', function () {
// 1. Identify your Carousel
var myCarousel = document.getElementById('Carousel1');
myCarousel.addEventListener('slid.bs.carousel', function (event) {
// 2. Specify which slide (0 is first, 1 is second, etc.)
// Let's say you want the 2nd slide to trigger the action:
if (event.to === 1) {
// 3. Identify the Accordion Panel ID you want to open
var panelElement = document.getElementById('Accordion1-collapse1');
if (panelElement) {
var bsCollapse = new bootstrap.Collapse(panelElement, {
toggle: false // Ensures it stays open if already open
});
bsCollapse.show();
}
}
});
});
</script>
-
Beth
-

- Posts: 128
- Joined: Mon Jan 15, 2018 10:55 pm
Re: Carousel activates Accordian?
Thank you so much Crispy. I thought that there should be a way. I'll work on it and let you know.
- BaconFries
-

- Posts: 6301
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Carousel activates Accordian?
Thank you so much Crispy?
- crispy68
-

- Posts: 3208
- Joined: Thu Oct 23, 2014 12:43 am
- Location: Acworth, GA
- Contact:
-
Beth
-

- Posts: 128
- Joined: Mon Jan 15, 2018 10:55 pm
Re: Carousel activates Accordian?
Oops!
Thank you Mr. BaconFries. I wasn't paying attention. You both have been so helpful, as is everyone else here on the forum.
Thank you Mr. BaconFries. I wasn't paying attention. You both have been so helpful, as is everyone else here on the forum.
- VictorKrs
-

- Posts: 425
- Joined: Sun May 17, 2020 8:08 pm
Re: Carousel activates Accordian?
Dear BaconFries!
Something doesn't work for me. Or is there something I didn't understand?
Project link: https://drive.google.com/file/d/1xAoG9m ... sp=sharing
Victor
Something doesn't work for me. Or is there something I didn't understand?
Project link: https://drive.google.com/file/d/1xAoG9m ... sp=sharing
Victor
- crispy68
-

- Posts: 3208
- Joined: Thu Oct 23, 2014 12:43 am
- Location: Acworth, GA
- Contact:
- VictorKrs
-

- Posts: 425
- Joined: Sun May 17, 2020 8:08 pm
Re: Carousel activates Accordian?
Hello, dear Ron!
I tried to implement the idea (based on the advice), but something didn't work:(
As always, Ron, you turn a fairy tale into reality!
I find that this functionality can be applied in a number of cases.
Do you share the demo file?
Victor
I tried to implement the idea (based on the advice), but something didn't work:(
As always, Ron, you turn a fairy tale into reality!
I find that this functionality can be applied in a number of cases.
Do you share the demo file?
Victor
- crispy68
-

- Posts: 3208
- Joined: Thu Oct 23, 2014 12:43 am
- Location: Acworth, GA
- Contact:
Re: Carousel activates Accordian?
@victor,
Keep in mind, this only works if the carousel is set to 'flexible' and the accordion is set to 'jquery'. The code may change if you want to use a different set up.
For the accordion, make sure you insert the same number of panels as there are slides in the carousel and set in the accordion options:
Type = jQuery UI
Active Panel = 0
Enter the following code in the page HTML in the 'Before </body>' tag:
Change 'Carousel1' above to the ID of your carousel and 'Accordion1' to the ID of your accordion.
Keep in mind, this only works if the carousel is set to 'flexible' and the accordion is set to 'jquery'. The code may change if you want to use a different set up.
For the accordion, make sure you insert the same number of panels as there are slides in the carousel and set in the accordion options:
Type = jQuery UI
Active Panel = 0
Enter the following code in the page HTML in the 'Before </body>' tag:
Code: Select all
<script>
$(document).ready(function(){
$('#Carousel1').on('slide.bs.carousel', function(e){
var nextIndex = $(e.relatedTarget).index();
$("#Accordion1").accordion("option","active",nextIndex);
});
});
</script>
- VictorKrs
-

- Posts: 425
- Joined: Sun May 17, 2020 8:08 pm
Re: Carousel activates Accordian?
Everything is working! Super!
Thanks a lot for your help, Ron!
Thanks a lot for your help, Ron!
-
Beth
-

- Posts: 128
- Joined: Mon Jan 15, 2018 10:55 pm
Re: Carousel activates Accordian?
This is a great and useful code. Thank you.
How about Accordian Controls Carousel? Would that be some specific javacript, built in events (which I can't get to work) or something similar but opposite to the carousel to accordian code? That would be very valuable, too.
How about Accordian Controls Carousel? Would that be some specific javacript, built in events (which I can't get to work) or something similar but opposite to the carousel to accordian code? That would be very valuable, too.
- crispy68
-

- Posts: 3208
- Joined: Thu Oct 23, 2014 12:43 am
- Location: Acworth, GA
- Contact:
Re: Carousel activates Accordian?
@beth,
I'm sure it can be done. Is this what you need as your original question was for the carousel to open/close the accordion?
I would assume you would want the carousel not to auto slide thru the slides and only slide when the accordion is selected correct?
I'm sure it can be done. Is this what you need as your original question was for the carousel to open/close the accordion?
I would assume you would want the carousel not to auto slide thru the slides and only slide when the accordion is selected correct?
-
Beth
-

- Posts: 128
- Joined: Mon Jan 15, 2018 10:55 pm
Re: Carousel activates Accordian?
Yes, when each accordian panel is clicked, it should open the cooresponding slide on the carousel. I tried messing with the previous code to no avail.
The first code is great! Thank you.
The first code is great! Thank you.
- crispy68
-

- Posts: 3208
- Joined: Thu Oct 23, 2014 12:43 am
- Location: Acworth, GA
- Contact:
Re: Carousel activates Accordian?
I have the opposite working.
Since there are 4 possible combinations of using a carousel and accordion together, it may be easier for me to create an extension that would handle the coding portion if there were enough interest in such a thing. Let me know in the comments if you are interested and would use it.
Since there are 4 possible combinations of using a carousel and accordion together, it may be easier for me to create an extension that would handle the coding portion if there were enough interest in such a thing. Let me know in the comments if you are interested and would use it.
-
Beth
-

- Posts: 128
- Joined: Mon Jan 15, 2018 10:55 pm
Re: Carousel activates Accordian?
Wow! Who would't use this.
It's perfectly responsive in a grid and sometimes you might want one to the right (or below in responsive) or vice-versa or versa-versa again. You can make it with the built in carousel buttons or independent ones, too.
Being able to have it how you want would be very useful.
Thank you for your help and attention.
It's perfectly responsive in a grid and sometimes you might want one to the right (or below in responsive) or vice-versa or versa-versa again. You can make it with the built in carousel buttons or independent ones, too.
Being able to have it how you want would be very useful.
Thank you for your help and attention.
- VictorKrs
-

- Posts: 425
- Joined: Sun May 17, 2020 8:08 pm
Re: Carousel activates Accordian?
Oh, Ron! Your initiative is wonderful! Having this advanced functionality in the form of an extension in the arsenal of an ordinary WWB user will, of course, help implement ideas more simply and quickly (remembering you with a kind word every time). I'm for it, with both hands!
Victor
Victor