Extend domMaker to set event listeners

print-window-tiddler
Jeremy Ruston 2013-10-26 13:13:45 +01:00
rodzic f8f524d378
commit b474d8c13d
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -114,6 +114,7 @@ children: array of further child nodes
innerHTML: optional HTML for element
class: class name(s)
document: defaults to current document
eventListeners: array of event listeners (this option won't work until $tw.utils.addEventListeners() has been loaded)
*/
$tw.utils.domMaker = function(tag,options) {
var doc = options.document || document;
@ -133,6 +134,9 @@ $tw.utils.domMaker = function(tag,options) {
$tw.utils.each(options.attributes,function(attribute,name) {
element.setAttribute(name,attribute);
});
if(options.eventListeners) {
$tw.utils.addEventListeners(element,options.eventListeners);
}
return element;
};