[Solved] How to create reusable UI control using JavaScript [closed]
Look into javascript templating. See mustache.js for one example. e.g. <script type=”text/template” id=”template”> {{#elements}} <div id=”{{id}}”> {{content}} </div> {{/elements}} </script> And your JavaScript: var view = { “elements”: [ { id: “one”, content: “Lorem ipsum dolor” }, { id: “two”, content: “Sit amet consectetur” } ] } var template = document.getElementById(“template”).innerHTML; var output = Mustache.render(template, … Read more