Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3481438
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:26:54+00:00 2026-05-18T10:26:54+00:00

I wanted to try out jQuery Templates after being inspired by these 2 blog

  • 0

I wanted to try out jQuery Templates after being inspired by these 2 blog postings

  • http://encosia.com/2010/11/10/composition-with-jquery-templates-why-and-how/
  • http://encosia.com/2010/10/05/using-external-templates-with-jquery-templates/

Well, it’s not quite working for me. If I have the template code on the page itself it works fine, but loading remotely isn’t working for me. It appears the template is being retrieved ok. what is wrong here?

External template:

<script id="contactsTemplate" type="text/x-jquery-tmpl">
  <table class="contacts">
    <thead><tr><td class="ui-helper-hidden">Id</td><td>Name</td><td>City</td><td>State</td></tr></thead>
    <tbody>
    {{each contact}}
        {{tmpl($value) '#contactTemplate'}}
    {{/each}}
    </tbody>
  </table>
</script>

<script id="contactTemplate" type="text/x-jquery-tmpl">
    <tr><td class="ui-helper-hidden">${id}</td><td>${name}</td><td>${city}</td><td>${state}</td></tr>
</script>

On my page I’m using this code to retrieve and load the template:

var contacts = {
    contact: [
        { id: 1, name: "John Green", city: "Orange Beach", state: "AL" },
        { id: 2, name: "Sam Thompson", city: "Pensacola", state: "FL" },
        { id: 3, name: "Mary Stein", city: "Mobile", state: "AL" }
    ]
};

$("#ShowDataRemote").button().click(function() {
    $.get('templates/Contact.htm', function(template) {
        alert(template);
        $.tmpl(template, contacts).appendTo("body");
        alert("async done");
    });
});

Update:

A new blog post on Encosia explains this question and answer…

http://encosia.com/2010/12/02/jquery-templates-composite-rendering-and-remote-loading/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:26:55+00:00Added an answer on May 18, 2026 at 10:26 am

    That simple remote loading technique won’t work with composite templates, since the string you’re loading isn’t a valid template itself. You can get it working by changing your click handler like this:

    $("#ShowDataRemote").button().click(function() {
      $.get('templates/Contact.htm', function(template) {
        // Inject the template script blocks into the page.
        $('body').append(template);
    
        // Use those templates to render the data.
        $('#contactsTemplate').tmpl(contacts).appendTo("body");
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read about Single-Page Applications recently and wanted to try one out. After watching
I wanted to install pinax and other dependent packages listed at http://pypi.pinaxproject.com I try
I wanted to try out an example you can find here: http://php.net/manual/en/function.include.php , but
I just started out with Python and wanted to try out tornado. Running the
I just discovered forge and wanted to try it out at once. I closely
I wanted to try out Cassandra, and thought the easiest way to get up
I wanted to try out some new features in Clang, and I was referred
I just wanted to try out some shaders on a flat image. Turns out
I'm working though SICP and wanted to try out some of the examples in
I'm currently using hbase with my Python apps and wanted to try out Amazon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.