* @param {String} newHTML - HTML to insert / replace.
* @param {String} newJS - Javascript to run after the insertion.
* @param {Boolean} replaceChildNodes - Replace only the childnodes, alternative is to replace the entire node.
+ * @return {Array} The list of new DOM Nodes
*/
var domReplace = function(element, newHTML, newJS, replaceChildNodes) {
var replaceNode = $(element);
runTemplateJS(newJS);
// Notify all filters about the new content.
event.notifyFilterContentUpdated(newNodes);
+
+ return newNodes.get();
}
+
+ return [];
};
/**
* @param {jQuery|String} element - Element or selector to prepend HTML to
* @param {String} html - HTML to prepend
* @param {String} js - Javascript to run after we prepend the html
+ * @return {Array} The list of new DOM Nodes
*/
var domPrepend = function(element, html, js) {
var node = $(element);
if (node.length) {
// Prepend the html.
- node.prepend(html);
+ var newContent = $(html);
+ node.prepend(newContent);
// Run any javascript associated with the new HTML.
runTemplateJS(js);
// Notify all filters about the new content.
event.notifyFilterContentUpdated(node);
+
+ return newContent.get();
}
+
+ return [];
};
/**
* @param {jQuery|String} element - Element or selector to append HTML to
* @param {String} html - HTML to append
* @param {String} js - Javascript to run after we append the html
+ * @return {Array} The list of new DOM Nodes
*/
var domAppend = function(element, html, js) {
var node = $(element);
if (node.length) {
// Append the html.
- node.append(html);
+ var newContent = $(html);
+ node.append(newContent);
// Run any javascript associated with the new HTML.
runTemplateJS(js);
// Notify all filters about the new content.
event.notifyFilterContentUpdated(node);
+
+ return newContent.get();
}
+
+ return [];
};
return /** @alias module:core/templates */ {
* @param {JQuery} element - Element or selector to replace.
* @param {String} newHTML - HTML to insert / replace.
* @param {String} newJS - Javascript to run after the insertion.
+ * @return {Array} The list of new DOM Nodes
*/
replaceNodeContents: function(element, newHTML, newJS) {
- domReplace(element, newHTML, newJS, true);
+ return domReplace(element, newHTML, newJS, true);
},
/**
* @param {JQuery} element - Element or selector to replace.
* @param {String} newHTML - HTML to insert / replace.
* @param {String} newJS - Javascript to run after the insertion.
+ * @return {Array} The list of new DOM Nodes
*/
replaceNode: function(element, newHTML, newJS) {
- domReplace(element, newHTML, newJS, false);
+ return domReplace(element, newHTML, newJS, false);
},
/**
* @param {jQuery|String} element - Element or selector to prepend HTML to
* @param {String} html - HTML to prepend
* @param {String} js - Javascript to run after we prepend the html
+ * @return {Array} The list of new DOM Nodes
*/
prependNodeContents: function(element, html, js) {
- domPrepend(element, html, js);
+ return domPrepend(element, html, js);
},
/**
* @param {jQuery|String} element - Element or selector to append HTML to
* @param {String} html - HTML to append
* @param {String} js - Javascript to run after we append the html
+ * @return {Array} The list of new DOM Nodes
*/
appendNodeContents: function(element, html, js) {
- domAppend(element, html, js);
+ return domAppend(element, html, js);
},
};
});