I'm not sure if I'm asking this question correctly, but how do I access an object's reference variable?
For example,
var datagrid = new DataBaseGrid();
console.log(datagrid);
DatabaseGrid.prototype.initializeGrid = function(grid) {
var self = this;
console.log(self); //self references same object as datagrid
grid.setCellRenderer("action", new CellRenderer({
render: function(cell, id) {
cell.innerHTML+= "<i onclick=\""+self+".deleteRow("+id+");\" class='fa fa-trash-o' ></i>";
console.log(cell.innerHTML);
}
}));
};
For cell.innerHTML, I want to replace self with the object reference, datagrid. So the cell's HTML will render as the following if id is 55:
<i onclick="datagrid.deleteRow("55")"; class='fa fa-trash-o' ></i>
Instead, I'm getting an error Uncaught SyntaxError: Unexpected identifier (index):1 when clicking on that element.
The reason why I want to do this is because I have other DataBaseGrid objects that will use initializeGrid, and I don't want to hard-code only one object reference to it.
<i>is neither keyboard nor screen reader accessible. To fix keyboard, make it a real<button>. To fix screen reader, you need some sort of text content in addition to the icon. One way is to usearia-label. Fixing both issues:<button onclick="datagrid.deleteRow("55")"; aria-label='delete'><i class='fa fa-trash-o' ></i></button>.