Decode html string in JQuery Mobile template

I am using jquery templates which I populate using an ajax request. However, one of the values returned is encoded HTML. How can I encode it?

I have tried using ${$.mobile.html(Body).text()} but that didn't work for me.

My code:

Domain.Discussion.ListView = Domain.Discussion.ListView || {
    DiscussionPage: (function () {
        var onGetDiscussionSuccess = function (data) {
            $("#discussionsList ul").remove();
            $("#discussionListItem").tmpl(data.DiscussionsResult).appendTo("#discussionsList", function () {
                reloadAndFixPanelContent()
            });
        }

        var onGetDiscussionError = function () {
            console.log("Error occured when retrieving discussions");
        }

        $.ajax({
            url: absolutePath + "Discussions",
            headers: { "Accept": "application/json; odata=verbose" },
            success: onGetDiscussionSuccess,
            error: onGetDiscussionError
        });
    }())
};

Html:

<!-- Discussion replies -->
<script id="replies" type="text/x-jquery-tmpl">
<div class="message message-first">
    <div class="message-header">
        <div class="message-header-user">
            <h1>${Author}</h1>
            <h2>Role not set yet</h2>
        </div>
        <div class="message-header-date">${Created}</div>
    </div>
    <div class="message-content">
        <span>${$.mobile.html(Body).text()}</span>
        <hr />
    </div>
</div>
</script>
<!-- /Discussion replies -->

Answers


After searching and searching I finally found the solution here: jQuery tmpl: How do I render Html?

Using {{html Body}} in my template worked like a charm.


Need Your Help

Two of the Same UIView removefromsuperview error

ipad uiview uiviewcontroller

I'm trying to remove a UIView that is initialised when a button is clicked. I've clicked that button twice, so two of the same UIView appear. I can remove the first one no problem but when I try to...

AJAX HtmlEditorExtender and getting text from the textbox?

c# asp.net .net ajax htmleditorextender

I'm just starting to get to grips with web development and trying to build up some experience.