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

  • Home
  • SEARCH
  • 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 8058211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:16:55+00:00 2026-06-05T09:16:55+00:00

First, here is a JSfiddle with my work: http://jsfiddle.net/xzGxR/ The JavaScript: function dataClonePrototype(JSOtarget, ElementPrototype,

  • 0

First, here is a JSfiddle with my work: http://jsfiddle.net/xzGxR/

The JavaScript:

function dataClonePrototype(JSOtarget, ElementPrototype, callback) {
    for (i = 0; i < JSOtarget.length; i++) {
        var TargetElement;
        if (!Eclone) { // Only create it on first interval
            TargetElement = $(ElementPrototype);
            var Eclone = TargetElement.clone(); // We only want to create a copy of this clone...
        } else {
            TargetElement = Eclone.clone().insertAfter(ElementPrototype);
        }
        callback(TargetElement, JSOtarget[i]);
    }
}

var returnedJSO = 
{
    "Animals": [
        {
            "Title": "Dogs",
            "Amount": 300
        },
        {
            "Title": "Pigs",
            "Amount": 230
        },
        {
            "Title": "Cats",
            "Amount": 340
        }
    ]
}

dataClonePrototype(returnedJSO.Animals, "section#animals", function(Element, JSOtargetAtKey) {
    Element.children("header").html(JSOtargetAtKey.Title);
    Element.children("article").html(JSOtargetAtKey.Amount);
});​

And the HTML:

<section id="animals">
     <header></header>
     <article></article>
</section>​

The output should (visually) look like this:

Dogs
300
Pigs
230
Cats
340

Yet, it looks like this.

Dogs
300
Cats
340
Pigs
230
Cats
340

The goal of this is to use the HTML and create clones of it – then populate these clones with data from the javascript object. It should populate like this:

<section id="animals">
   <header>Dogs</header>
   <article>300</article>
</section>​

Something is wrong with the code that clones, but I can’t figure out what. Any advice/help is really appreciated.

  • 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-05T09:16:57+00:00Added an answer on June 5, 2026 at 9:16 am

    Try this jsFiddle

    function dataClonePrototype(JSOtarget, ElementPrototype, callback) {
    
        $TargetElement = $(ElementPrototype);
        for (i = 0; i < JSOtarget.length; i++) {
    
            var $Eclone = $TargetElement.clone(); // We only want to create a copy of this clone...
    
            callback($Eclone, JSOtarget[i], $TargetElement);
        }
    }
    
    
    dataClonePrototype(returnedJSO.Animals, "section#animals", function($Element, JSOtargetAtKey, $Prototype) {
        $Element.children("header").html(JSOtargetAtKey.Title);
        $Element.children("article").html(JSOtargetAtKey.Amount)
            $Element.insertAfter($Prototype);
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking at the example here - http://jsfiddle.net/uqYeQ/3/ The first row behaves as expected, returning
I have a fiddle here http://jsfiddle.net/WULsZ/1/ I load jQuery first and the code is
First of all, here is a JSFiddle which has the problem I'm getting. http://jsfiddle.net/UG66K/9/
The implementation is here: http://jsfiddle.net/chp8y/1/ If you hover over the first box, #1, you
I've got two problems here: http://jsfiddle.net/BtGtT/3 The first problem is that the footer should
http://jsfiddle.net/JamesKyle/y7hBQ/ I'm making a simple jquery counting function that adds the following classes: First
First question here. I'm trying Javascript objects. Here's my code: function main(){ document.onkeydown =
I got a CSS question related to this fiddle: http://jsfiddle.net/r584e/ Here the relevant screenshot
In the fiddle here http://jsfiddle.net/mjmitche/KvwGw/21/ , when you submit the form, a new form
I have a jQuery animation example here : http://jsfiddle.net/p7Eta/ I would like all the

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.