-
Notifications
You must be signed in to change notification settings - Fork 0
Description
review existing setup and see if it can be improved on, compare to this snippet or implement if not robust enough to handle data
function CreatePage(rowDataObj, templateId) {
var template = $($("#" + templateId).html());//copies the html inside the template file name, (for reusability, dont taint the original)
template.find("*[data-display]").each(function(k, v) { //loop through each of the data-display attributes
var _this = $(this);
var displayName = _this.attr("data-display");
var displayValue = !isEmpty(rowDataObj[displayName]) ? rowDataObj[displayName] : "";
if(!isEmpty(displayValue) && typeof displayValue === "string") displayValue = displayValue.trim();
var tagName = _this.prop("tagName");
if(tagName === "INPUT") {
_this.attr('value', displayValue);
} else {
_this.text(displayValue);
}
});
return template;
};