2

I am a JS, html beginner and trying to understand how to define/create a html representation of a data object.

Say I have a list of people (in JSON for example) where each person has the following properties: firstName, lastName, age, photo, description.

How would you normally display this list in html?

I assume that somewhere is a div place holder for the list which then gets populated in JS but I'm not sure how the template for the person itself is defined.

Is there a recommended way of doing this sort of thing?

If someone can show me an example that would be great.

3 Answers 3

1

There are plenty of frameworks for templates, e.g.:

Sign up to request clarification or add additional context in comments.

Comments

1

Have a look at http://handlebarsjs.com/ for a start. This will take your json and format it the way you want.

You can also use jquery Ajax method and then just loop through your results and generate HTML.

Comments

0

There is also http://code.google.com/p/distal for starters. It has a syntax familiar to HTML coders.

<div data-qtext="obj.firstName"></div>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.