Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thehitechpanky committed Jun 15, 2020
2 parents 6415c07 + 098d177 commit e353a03
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class DynamicTable {
headData,
head2Data,
footData,
addFilter
addFilter,
functionArray
} = this.paramObject;
if (addFilter) {
this.divNode.appendChild(this.filterNode);
Expand All @@ -42,6 +43,16 @@ class DynamicTable {
} else {
this._addTableDivision(tableNode, `tfoot`, headData, head2Data);
}
if (functionArray) {
functionArray.forEach(currentObject => {
let {
className,
eventName,
functionName
} = currentObject;
this._attachFunctionToClassNodes(this.divNode,className, eventName, functionName);
});
}
return this.divNode;
}

Expand Down Expand Up @@ -228,16 +239,6 @@ class DynamicTable {
} else {
this._addTableDataRowsFromObject();
}
if (functionArray) {
functionArray.forEach(currentObject => {
let {
className,
eventName,
functionName
} = currentObject;
this._attachFunctionToClassNodes(className, eventName, functionName);
});
}
}

_addTableDataRowsFromObject() {
Expand Down Expand Up @@ -277,8 +278,8 @@ class DynamicTable {
this.countNode.appendChild(textNode);
}

_attachFunctionToClassNodes(className, eventName, functionName) {
let classNodes = document.getElementsByClassName(className);
_attachFunctionToClassNodes(baseNode,className, eventName, functionName) {
let classNodes = baseNode.querySelectorAll(`.${className}`);
Array.from(classNodes).forEach(element => {
element.removeEventListener(eventName, functionName);
element.addEventListener(eventName, functionName);
Expand Down

0 comments on commit e353a03

Please sign in to comment.