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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:55:16+00:00 2026-06-09T22:55:16+00:00

Basically, if you have a purely JS app (that get info from socket.io, or

  • 0

Basically, if you have a purely JS app (that get info from socket.io, or from a server with ajax request), and you need to show this data after processing it, what technique are you using?

Currently i’m creating the elements manually with code like

var myDiv = new Element('div',{ /* options */);

And injecting it where I need making all the DOM structure. I find this hard to maintain and especially for those designers that can code html, but they can’t code html from JS.

Is there any way that will improve this process? Is it better to get the html from ajax? or just make html code in a string?

I’m looking for the most optimal in terms of maintenance and resources.

  • 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-09T22:55:18+00:00Added an answer on June 9, 2026 at 10:55 pm

    What you’re looking for is a “template”.

    You have an HTML template (some divs, etc) and you bind this with the datas you provide in JS. Then, with whatever template engine you’re using, you can get the full HTML.

    Here are some template engines out there:

    • https://github.com/flatiron/plates
    • http://embeddedjs.com/

    And a code sample using plates:

    var Plates = require('plates'); // specific to node.js, see for client-side use
    
    var html = '<div id="test">Old Value</div>';
    var data = { "test": "New Value" };
    
    var output = Plates.bind(html, data); 
    console.log( output ); // '<div id="test">New Value</div>'
    

    You can store your templates either in a single file (“templates.html”) loaded through ajax, or by storing it in the HTML page (not really recommended for maintenance matters).

    If you store them all in an external file, you can do something like this:

    templates.html:

    <!-- text/html isn't parsed by the browser so we can put anything in it -->
    <script type="text/html" id="template1"> 
        <!-- put your template in there
    </script>
    

    And you can get its content through getElementById( 'template1' ).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically have a program that filters records from one excel file to another
I basically have 7 select statements that I need to have the results output
This is purely an Excel sheet question. I have a time span that is
I basically have a table with headers that I read in from a DB
I basically have a form inside of Flash that I need to submit to
I basically have an ajax function which gets the latest posts from a database,
I basically have three tables, posts, images and postimages (this simply contains the ids
I basically have a server set up and I'm accepting new clients(UNIX) and i'm
I basically have the same question as this guy .. The example in the
I have a UIView that contains a couple UIButtons that I am animating from

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.