This is driving me mad:
// Get the comment template
var comment = $('#CommentTemplate').html();
// Delete all entered text
$("textarea#NewComment").val('');
// Get comments returned ID
var ThisCommentsID = data.substring(2, data.length);
var d = new Date();
// Replace comment variables
comment = comment.replace("{CID}", ThisCommentsID);
comment = comment.replace("{USERNAME}", CurrUsername);
comment = comment.replace("{BODY}", Message);
comment = comment.replace("{GRAV}", GravHash);
comment = comment.replace("{CLEARDATE}", GravHash);
comment = comment.replace("{ISODATE}", ISODateString(d));
comment = comment.replace("{USERURL}", RelURL + CurrUsername);
// Add it
$('#comment-total-wrap').prepend(comment);
This basically works 100% fine, dynamically adding a comment to the list with an AJAX query, but all the values on the template are coming out still as {CID}, {GRAV} etc etc. It's not throwing any errors, the replace isn't working.
I've tried:
comment = comment.replace("{BODY}", Message);
as well but it still just shows as {BODY} on the output HTML. Any help appreciated.
The HTML template on the page is:
<div id="CommentTemplate" style="display:none;">
<div id="cid{CID}" class="comment-wrapper">
<div id="CommentHead" class="comment-head ch-highlight">
<div class="comment-date">
<abbr class="timeago" title="{ISODATE}" id="Timeago{CID}">{CLEARDATE}</abbr>
</div>
<div class="comment-author">
Written by <a id="CommentAuthorLink" title="Visit this game makers profile" href="{USERURL}">{USERNAME}</a>
</div>
</div>
<table class="comment-body" width="100%">
<tr>
<td width="100" valign="top" align="center">
<a id="GravLink" title="{USERNAME} makes games with Construct 2" href="{USERURL}"><img id="GravatarComment" title="{USERNAME}'s Gravatar" class="comment-avatar" src="http://www.gravatar.com/avatar/{GRAV}?r=pg&s=80" /></a>
</td>
<td valign="top">
<div class="comment-txt">
{BODY}
</div>
</td>
</tr>
</table>
<div class="clear"></div>
</div>
</div>