Skip to content

integrate cope snippet into core #1

@JoeCrash

Description

@JoeCrash

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;
};

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions