Currently, I cannot clear the div container before adding new elements. (The whole div is cleared when empty(), I donβt want this. I just want to delete the existing elements of the book holder. Is there something that I am doing wrong, and / or maybe this is due to the "text / template" "script?)
HTML snippet
<div class="component">
<ul id="Maincontainer" class="align">
<script type="text/template" id="template">
<li id="bookHolder" class="bookHolder">
<figure class="book">
<ul class="hardcover_front">
<li>
<img src="{{imgURL}}" alt="" width="100%" height="100%">
</li>
<li></li>
</ul>
</figure>
</li>
</script>
</ul>
</div>
jquery code snippet
$.get( "URL", function(data) {
var entry = $(data).find("entry");
entry.each(function() {
var template = $("#template").html();
$("#Maincontainer").append(template.replace("{{bookName}}",
bookName).replace("{{summary}}", summary).replace("{{price}}", price).replace("{{seller}}", artist).replace("{{imgURL}}", image)
.replace("{{href}}", href).replace("{{category}}", category));
});
});
source
share