Last active
November 20, 2022 10:46
-
-
Save imuhammadshoaib/84881416f91ec47f7ac9ecfdc4a8b7de to your computer and use it in GitHub Desktop.
Add Read More & Read Less Button on Collection Description
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if collection.description != blank %} | |
<div class="collection--description"> | |
{% capture readmore %} | |
<div id="truncated">{{ collection.description | strip_html | truncatewords: 10, "... <a class='read-more-collection' data-no-instant>Read More</a>" }}</div> | |
<div id="fullDescription" style="display: none">{{ collection.description | append: " <a class='read-more-collection' data-no-instant>Read Less</a>" }}</div> | |
{% endcapture %} | |
{{ readmore }} | |
</div> | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Custom jQuery for colllection page --> | |
{% if template.name == 'collection' %} | |
<script type="text/javascript"> | |
jQuery('.read-more-collection').click(function(){ | |
if(jQuery('#truncated').is(":visible")){ | |
jQuery('#truncated').hide(); | |
jQuery('#fullDescription').show(); | |
} | |
else{ | |
jQuery('#truncated').show(); | |
jQuery('#fullDescription').hide(); | |
} | |
}); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment