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 7931815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:49:47+00:00 2026-06-03T20:49:47+00:00

I am using the jQuery templates plugin to render separate html files as templates.

  • 0

I am using the jQuery templates plugin to render separate html files as templates. One of my templates look like this:

<div class="row">
    <div class="span4">
        test1
    </div>
    <div class="span4">
        test2
    </div>
    <div class="span4">
       test3
    </div>
</div>

For testing purposes I am not actually rendering any data yet.

When I debug with firebug, I can see that my ajax call fetches the correct html (exactly as the above). I then use a json object (stored in a var called data) to populate my retrieved template (stored in a var called template) like so:

$.tmpl(template, data).appendTo('#person-item-placeholder');

The resulting html (as inspected by firebug) is this (notice the missing div element)

<div id="person-item-placeholder">
    <div class="span4">test1‌</div>
    <div class="span4">‌test2‌</div>
    <div class="span4">test3‌</div>
</div>

How do I prevent the template plugin from removing that element?

  • 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-06-03T20:49:48+00:00Added an answer on June 3, 2026 at 8:49 pm

    The jQuery.tmpl documentation is sort of vague in this area

    On the surface, what you have tried should work but one of the template parameter options reads :

    The template parameter can be …. An HTML element (or jQuery object
    that wraps an element) whose content is to be used as the template.

    The key word here is “content”, in other words the wrapper is discarded though it doesn’t say this occurs when a string is passed. Ignoring that, the symptom is exactly as described in the question.

    A possible solution would be to pre-wrap the template in a dummy container, eg a div.

    If I’m right, then this should work :

    $.tmpl('<div>+'template+'</div>', data).appendTo('#person-item-placeholder');
    

    Or maybe :

    $.tmpl($(template).wrap('<div/>'), data).appendTo('#person-item-placeholder');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using JQuery it possible to clone a Div like this and change add a
I'm using the following jQuery ( https://github.com/blueimp/jQuery-File-Upload ) script to upload files. This script
I'm using jQuery Templates from within the jQuery UI Autocomplete plugin so that I
I'm trying to learn how to use jQuery templates using this old ScottGu's blog
I'm using the jQuery template plugin to generate HTML from JSON data which the
I'm using official jQuery template plugin: http://api.jquery.com/category/plugins/templates/ I need some boolean check to know
After loading a PHP template (using jQuery's load function), this simple script won't make
Context: HTML widgets generated using a Django ModelForm and template, jQuery 1.3.2, JavaScript on
I'm using JQuery Form Plugin as follows: $('document').ready( -> options = beforeSubmit: markComment $('.comment_form').ajaxForm(options)
I am using a twitter plugin that is being set with these options: jQuery(function($){

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.