Hi I am trying to create a list that is partially shown and if you click read more you will be able to see all the list. I have found this plugin: https://github.com/solarmosaic/jquery-show-first
However when I try to use it on newly inserted HTML from javascript it does not work. It works if the HTML is in the HTML file in the beginning.
Here is part of my code:
var associatedEntities = associated[a].split("|");
var personDone = false;
var placeDone = false;
var keywordDone = false;
var itemDone = false;
for (var d = 0; d<associatedEntities.length; d++){
if(associatedEntities[d].includes("@")){
var contents = associatedEntities[d].split('@');
if(associatedEntities[d].includes('person/')){
if(personDone == false){
associatedWithHTML+="<ul class = \"show-first\" data-show-first-count=\"3\">";
personDone = true;
}
associatedWithHTML+="<li><a target=\"_blank\" href=\"PersonResult.html?id="+contents[0].trim()+"\" >"+contents[1]+"</a><br></li>";
}else if (associatedEntities[d].includes('place/')){
if(placeDone == false){
associatedWithHTML+="<ul class = \"show-first\" data-show-first-count=\"3\">";
placeDone = true;
}
associatedWithHTML+="<li><a target=\"_blank\" href=\"PlaceResult.html?id="+contents[0].trim()+"-"+contents[1]+"\" >"+contents[1]+"</a><br></li>";
}else if (associatedEntities[d].includes('item/')){
if(itemDone == false){
associatedWithHTML+="<ul class = \"show-first\" data-show-first-count=\"3\">";
itemDone = true;
}
associatedWithHTML+="<li><a target=\"_blank\" href=\"ItemResult.html?id="+contents[0].trim()+"\" >"+contents[1]+"</a><br></li>";
}
}else{
if(keywordDone == false){
associatedWithHTML+="<ul class = \"show-first\" data-show-first-count=\"3\">";
keywordDone = true;
}
associatedWithHTML+="<li><span>"+associatedEntities[d]+"</span><br></li>";
}
}
}
associatedWithHTML+="</ul><hr></div>";
document.getElementById("DeedDate").innerHTML+=newHTML+associatedWithHTML+"</div>";