This is in reference to this post which included a link to a revised version of the show/hide (collapsing/expanding) script. That one was designed specifically for entries. Most people use this script for their comments to, so I made a slight change to it so that you can use ONE function that will work with both.
Here's the new function. I added a new, additional variable that needs to be passed to it: type. My changes to the first revision are in bold.
<script type="text/javascript">
function showHide(entryID, entryLink, htmlObj, type) {
if (type == "comments") {
extTextDivID = ('comText' + (entryID));
extLinkDivID = ('comLink' + (entryID));
} else {
extTextDivID = ('extText' + (entryID));
extLinkDivID = ('extLink' + (entryID));
}
if( document.getElementById ) {
if( document.getElementById(extTextDivID).style.display ) {
if( entryLink != 0 ) {
document.getElementById(extTextDivID).style.display = "block";
document.getElementById(extLinkDivID).style.display = "none";
htmlObj.blur();
} else {
document.getElementById(extTextDivID).style.display = "none";
document.getElementById(extLinkDivID).style.display = "block";
}
} else {
location.href = entryLink;
return true;
}
} else {
location.href = entryLink;
return true;
}
}
</script>
For the extended entries, the prefix "ext" is used for the name of the <div> – and when the javascript function is called, 'entry' is passed in. Basically this is the same as the first updated version, except now we pass in that extra value for type, which in this case is 'entry'.
<MTEntryIfExtended>
<div id="extLink<$MTEntryID$>">
<a href="<$MTEntryPermalink$>" name="ext<$MTEntryID pad="1"$>" onclick="showHide(<$MTEntryID$>,'<$MTEntryPermalink$>',this,'entry');return false;">Read More… ?</a>
</div>
<div id="extText<$MTEntryID$>" style="display: none">
<$MTEntryMore$>
<a href="#ext<$MTEntryID pad="1"$>" onclick="showHide(<$MTEntryID$>,0,this,'entry');return true;">? All done!</a>
</div>
</MTEntryIfExtended>
Then for the comments, I changed "ext" to "com" and for type: "comments":