-
AuthorPosts
-
March 9, 2016 at 1:09 pm #830726
DonWattz
ParticipantLooking to click the “Learn More” button under each person and have a section underneath appear. The sections should all be hidden at first then with each click, you can toggle them open or closed.
March 9, 2016 at 4:59 pm #831089John Ezra
MemberHey there,
Thanks for writing in! Regretfully this isn’t a feature offered by X. It could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this.
X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding. Take care!
March 11, 2016 at 1:15 pm #833897DonWattz
ParticipantI have something like this but I am still having problems. Is there anything you all can help with?
$(document).ready(function(){ $("#kevin").toggle(function(){ $("#kevinRow").removeClass("hiddenrow"); }); });
March 11, 2016 at 6:03 pm #834214Rad
ModeratorHi there,
I checked and it works as intended based on the code. Unless, it’s not something you wish to achieve. For example, like this,
jQuery ( function( $ ) { $('.section-expandable').css({ display: 'none' }); $('.section-trigger').on( 'touchend click', function( e ) { e.preventDefault(); $('.section-expandable').css({ display: 'none' }); $( $(this).attr('href') ).toggle('show'); } ); } );
This assumes that your button is in this format
[button href="#kevin" class="section-trigger"]Kevin[/button]
What you did are unique buttons with unique jQuery coding for each, hence harder to maintain and harder to connect to other buttons. Hence, the toggle is independent of each other (eg. when you toggle off, other contents are still displayed).
Thanks!
May 16, 2016 at 3:36 pm #994344azzacoward
ParticipantJust found this post. Totally awesome answer guys! Really helped me achieve an effect I wanted.
May 16, 2016 at 8:15 pm #994700Prasant Rai
ModeratorHappy to hear that. Feel free to ask us again. Have a great day! 🙂
June 20, 2016 at 1:14 pm #1051111uberphoto
ParticipantHey — this is fantastic! Any note on how to close the section after opening?
I did the below based on your above post, but, while it works, I’m sure there’s a wayyyyy more elegant method of doing it. 😛
jQuery ( function( $ ) { $('.section-collapse-trigger').on( 'touchend click', function( e ) { e.preventDefault(); $('.section-collapse').css({ display: 'block' }); $( $(this).attr('href') ).toggle('show'); } ); } );
June 20, 2016 at 1:58 pm #1051197Nabeel A
ModeratorHi again,
Thank you for writing in! Can you please share the page URL so we can take a look?
Thanks!
June 20, 2016 at 11:36 pm #1051925uberphoto
ParticipantThis reply has been marked as private.June 21, 2016 at 1:55 am #1052050Paul R
ModeratorHi,
Your code looks fine, kindly remove this line.
$(‘.section-collapse’).css({ display: ‘block’ });
eg.
jQuery ( function( $ ) { $('.section-collapse-trigger').on( 'touchend click', function( e ) { e.preventDefault(); $( $(this).attr('href') ).toggle('show'); } ); } );
Thanks
June 21, 2016 at 2:10 am #1052065uberphoto
ParticipantWill do — thanks! Is there a way to make the expand button scroll to the section as well? And the collapse to scroll to the section just below it?
June 21, 2016 at 3:43 am #1052159Lely
ModeratorHi There,
Please try updating the code to this:
jQuery(document).ready(function($){ $('#kevin.section-expandable').slideToggle(0); $('#kevin-trigger-button').on('touchend click',function(e){ e.preventDefault(); $('#kevin.section-expandable').slideToggle('slow') $('html, body').animate({ scrollTop: $("#kevin.section-expandable").offset().top }, 700, 'swing'); }) });
Update other codes as well.
Hope this helps.
June 21, 2016 at 11:23 am #1052766uberphoto
ParticipantThanks Lely — but doesn’t that remove the ability to have multiple sections without copying the code for every every ID?
June 21, 2016 at 12:59 pm #1052938Joao
ModeratorHi There,
IDs can be assigned just one time to one element, please try using class instead. A class can be assigned multiple times.
If you use class for your sections your code should look like this:
jQuery(document).ready(function($){ $('#kevin.section-expandable').slideToggle(0); $('#kevin-trigger-button').on('touchend click',function(e){ e.preventDefault(); $('.kevin.section-expandable').slideToggle('slow') $('html, body').animate({ scrollTop: $(".kevin.section-expandable").offset().top }, 700, 'swing'); }) });
Let us know if it works for you.
Thanks
Joao
June 21, 2016 at 4:04 pm #1053222uberphoto
ParticipantThanks!
I’ve basically got it to my needs (I removed all reference of IDs). I have added a close button that triggers the same script positioned absolutely on the top right of the section that expands. It gets mostly obscured — is there an offset I can do to prevent it from being scrolled past?
Finally, when the button is clicked to collapse, is there a way to scroll to the top of the section immediately below? Because it scrolls past about 90px.
::EDIT::
I’ve tweaked it a bit but there is still a scroll. I think it is the sticky header, because it does not happen on mobile.jQuery(document).ready(function($){ $('.section-expandable').slideToggle(0); $('.section-trigger').on('touchend click',function(e){ e.preventDefault(); $('.section-expandable').slideToggle('slow') $('html, body').animate({ scrollTop: $(".section-expandable").offset().top }, 700, 'swing'); }) });
Oh! Any way to increase performance on mobile? Though it could just be choppy because I currently have a large, but relatively sized-down image in it…>> Definitely helped resizing the photo. -
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-830726 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>