WordPress.org

Forums

Connections Business Directory
[Plugin: Connections] How do you apply jquery .toggle to hide/reveal bios? (6 posts)

  1. Jeff Mann
    Member
    Posted 4 years ago #

    I'm using a custom template and sorting within grouped categories. The short code I'm using is:

    [connections_list template_name='staff-card-bio' category='10,11,12' order_by='id|SORT_ACS']

    Within the custom template I'm using the following code to call the bio with a link.

    <a href="#" onclick="$('#hidden').toggle('fast');">Read <?php echo $entry->getFirstName() ?>'s Bio</a>
    <div id="hidden" style="display: none;"><?php echo $entry->getBio() ?></div>

    The problem I'm having is that in all four profiles that appear, every 'read bio' link reveals or hides only the first profile and never the profile it's paired with. What am I doing wrong?

  2. Jeff Mann
    Member
    Posted 4 years ago #

    This is what I'm trying to do.

    http://3rivers4cities1heart.com/?page_id=2

  3. shazahm1
    Member
    Plugin Author

    Posted 4 years ago #

    You code is close the hidden id needs to be unique for each displayed entry. Something like this:

    <a href="#" onclick="$('#hidden<?php echo $entry->getId() ?').toggle('fast');">Read <?php echo $entry->getFirstName() ?>'s Bio</a>
    <div id="hidden-<?php echo $entry->getId() ?>" style="display: none;"><?php echo $entry->getBio() ?></div>

    This will only work if an entry is displayed once. If it shows twice on a page there will be a conflict. You might be better off using the php function uniqid().

  4. Jeff Mann
    Member
    Posted 4 years ago #

    And close, yet again. I found that onclick, it would expand the correct bio, but jump to the top of the page. This was the final code that I used that seemed to work properly!

    <a href="#-<?php echo $entry->getId() ?>" onclick="$('#hidden-<?php echo $entry->getId() ?>').toggle('fast');">Read <?php echo $entry->getFirstName() ?>'s Bio</a>
    <div id="hidden-<?php echo $entry->getId() ?>" style="display: none;"><?php echo $entry->getBio() ?></div>

    Thank you!

  5. lahive
    Member
    Posted 4 years ago #

    Did you ever resolve this?

  6. fringer
    Member
    Posted 3 years ago #

    Jeff: Suddenly, that code doesn't work! Nothing happens when you click the link - and it was working fine.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Connections Business Directory
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic