lundi 30 mars 2015

Alternative solutions to creating HTML content dynamically in Javascript

I am working on a web project. (Absolutely no previous experience). This project requires retrieving lot of content from the server dynamically(Like on the click of button). I have JSON as the data interchange format. Now, the problem is, I have to display the content in some neat, formatted way. Like, collapsible lists, hyperlinks etc. I am currently using JavaScript for this purpose. Like this:



li = document.createElement("li");
li.innerHTML = "some_content";


I also need to add appropriate classes to those dynamically created elements in JavaScript as per the requirements of Bootstrap. But the code really looks very messy now. Are there any alternative solutions for avoiding all the dynamic creation of elements in JS, formatting etc.?


Aucun commentaire:

Enregistrer un commentaire