I have a function that creates a HTML table:
makeHTMLTable: function(array){
var table = document.createElement('table');
for (var i = 0; i < array.length; i++) {
var row = document.createElement('tr');
var cell = document.createElement('td');
cell.textContent = array[i];
row.appendChild(cell);
cell = document.createElement('td');
var msgButton = document.createElement('button');
msgButton.setAttribute("id", "msgButton" +i);
msgButton.textContent = "message";
msgButton.addEventListener("click", this.messageUser, false);
cell.appendChild(msgButton)
row.appendChild(cell);
table.appendChild(row);
}
return table;
},
I then have this function:
messageUser: function(){
debugger;
this.parentNode.parentNode.remove();
unMatch();
},
When I click the msgbutton I am expecting it to remove the whole row including the button itself and the little bit of text that comes back. i.e:
hello [msgbutton]
goodbye [msgbutton]
If i click [msgbutton] on the hello row it will look like this:
goodbye [msgbutton]
but so far this: this.parentNode.parentNode.remove();
is returning undefined..
EDIT:
I call this.retrieveMatches()
in an earlier promise
this.fetchMatches() returns an array
retrieveMatches: function(){
var tableResult = this.makeHTMLMatchesTable(this.fetchMatches(object));
var matches = document.getElementById('matches')
matches.parentNode.insertBefore(tableResult, matches);
},