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

ActiveRecord::RecordNotFound - before_action set_article

ruby-on-rails ruby activerecord

I'm attempting to create a Rails blog application and am having some issues implementing friendly urls. (Not the via the gem, I'm manually implementing them.) I am able to access the article's show...

Syntax error in compiling NLopt Fortran example code

fortran fortran90 fortran77 nlopt

I'm exercising the NLopt example from http://ab-initio.mit.edu/wiki/index.php/NLopt_Tutorial using Simply Fortran (gfortran compiler).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.