I am much more of a back-end guy than a Javascript guy. Forgive me for what is probably a Javascript/Jquery newbie question.
When I find myself writing code such this:
var rowDiv = "<div class='row small'> <div class='col-sm-8 small'>"
+ json['commentary'] + " – " + json['creation_date']
+ "</div><div class='col-sm-4 small'>by "
+ json['user']
+ "</div></div>"
$('#commentary-container').append(rowDiv)
My code smells detector flashes massive red lights and sounds deafening klaxons. Creating structured data in repeated string concatenation just seems wrong to me.
Is there a programmatic way to create new elements? That might look like;
var rowDiv = $.div().setclass('row small').append(
$.div().setclass('col-sm-8 small').html(json['commentary'])
) ...
or something similar?