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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:07:10+00:00 2026-06-06T11:07:10+00:00

I have seen a few tutorials on jQuery templates , which as far as

  • 0

I have seen a few tutorials on jQuery templates , which as far as I understand is outdataed , so I am trying to use .Clone I got it to work fine when I am only showing one result, but when I want to show an entire list of results it is not working, I am sure because of my bad jQuery. I want to clone the entire .template class fill it from each member of the response array , then add each newly cloned template to #fillresultsdiv , if anyone can help find what I’m doing wrong

here is jQuery:

                 success: function (msg) {
                    var events = [];
                    var obj = $.parseJSON(msg.d);
                    $(obj.res).each(function () {
                        var newRow = $('.template').clone()
                        newRow.$('.day').text($(this).attr('day')),
                            newRow.$('.dayofweek').text($(this).attr('dayofweek')),
                            newRow.$('.month').text($(this).attr('month')),
                            newRow.$('.title').text($(this).attr('title')),
                            newRow.$('.time').text($(this).attr('time')),
                        newRow.$('.venue').text($(this).attr('venue')),
                        newRow.$('.description').text($(this).attr('description'))
                        $('#fillresultsdiv').append(newRow);

Here is a sample response :

   d: "{"res":[{"day":"26","dayofweek":"Tue","month":"Jun","title":"Glen Hansard","venue":"Vic Theatre","time":"7:00 PM","ticketurl":"http://seatgeek.com/glen-hansard-t

and here is my template HTML:

    <div class="Template">
      <div class="accordian_head1">
        <div class="date_container">
          <a class="day"></a><br/><br/>
          <a class="dayofweek"></a><br/>
          <a class="month"></a>
        </div>
        <div class="title_container">
          <a class="title">Title</a>
          <a class="venue"><br/></a><a class="time"></a>
        </div>
        <div class="links">
          <a href=" + dr(36).ToString() + ?aid=854">Buy Tickets</a><br/>
          <a href="javascript:void(0)" onclick="fnAddToCalendar({ 'eventID' : '  dr(0).ToString() + '});">Watch</a><br/>
        <a href="#">Email</a><br/>
        <a href=""Calendar.aspx"">Calendar</a><br/>
    </div>
  </div>
  <div class="accordian_body1new"><a class="description"></a>
  </div>

This is all #fillresultsdiv is

     <div id="fillresultsdiv"></div> 
  • 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-06T11:07:11+00:00Added an answer on June 6, 2026 at 11:07 am
    // Parse the entire string, because `msg` is not an object,
    // so you can't use `msg.d`
    var obj = $.parseJSON( msg );
    
    $( obj.d.res ).each( function() {
        var newRow = $( '.template' ).clone();
    
        // Now loop through the object
        for ( var prop in this ) {
            if ( this.hasOwnProperty( prop ) ) {
    
                // Lucky for you, the keys match the classes :)
                $( '.' + prop, newRow ).text( this[ prop ] );
            }
        }
        $( '#fillresultsdiv' ).append( newRow );
    } );
    

    But you should definitely use a DocumentFragment to speed up the DOM manipulation and append everything at once. Because remember: the DOM is effin slow.

    var obj = $.parseJSON( msg );
    
    // Create a DocumentFragment
    var el = document.createDocumentFragment();
    $( obj.d.res ).each( function() {
        var newRow = $( '.template' ).clone();
        for ( var prop in this ) {
            if ( this.hasOwnProperty( prop ) ) {
                $( '.' + prop, newRow ).text( this[ prop ] );
            }
        }
    
        // Append to the DocumentFragment
        $( el ).append( newRow );
    } );
    
    // And append the DocumentFragment to the DIV
    $( '#fillresultsdiv' ).append( el );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen few py scripts which use this at the top of the
I have seen quite a few ways to output variables. Which of these ways
I have seen quite a few examples/tutorials on the web for doing one-one shared
I have seen quite a few tutorials on how to fade images in and
I have seen a few .NET apps use .db files. I am not new
I want to have 3 aligned parallel to each other. I have seen few
I have seen a few times people using -1 as opposed to 0 when
I have seen a few sites now where if you highlight text of an
I have seen a few posts regarding this issue but not one specific to
I have seen a few OSX apps that have a Special Characters menu item

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.