This commit implements STUD-1490, allowing creation of components on the container page. It also enables the delete and duplicate buttons now that new content can be created that would benefit. Note that it also creates shared functionality for adding components, and refactors the unit page to use it too.
21 lines
587 B
JavaScript
21 lines
587 B
JavaScript
define(["jquery", "underscore"], function($, _) {
|
|
|
|
/**
|
|
* Loads the named template from the page, or logs an error if it fails.
|
|
* @param name The name of the template.
|
|
* @returns The loaded template.
|
|
*/
|
|
var loadTemplate = function(name) {
|
|
var templateSelector = "#" + name + "-tpl",
|
|
templateText = $(templateSelector).text();
|
|
if (!templateText) {
|
|
console.error("Failed to load " + name + " template");
|
|
}
|
|
return _.template(templateText);
|
|
};
|
|
|
|
return {
|
|
loadTemplate: loadTemplate
|
|
};
|
|
});
|