I have registered an application event 'ShowModalEvent' in component-1 (Table) and handler in component-2. Component-2 (Modal Dialog) is part of component-1. I have added onclick function call (to show modal) to one of the table column data.
Component-1 - Helper
generateTableWithLink : function(component, callback) {
..
..
retRecords.forEach(function(row) {
fields.forEach(function(field){
if(field.name == 'Id') {
var showModalEvent = $A.get("e.c:ShowModalEvent");
tableData.appendChild(document.createElement('a'));
tableData.onclick = function() {
this.showPopup(component, row, showModalEvent);
}
tableData.children[0].appendChild(document.createTextNode(row[field.name]));
}
}
}
..
..
},
showPopup : function(component, row, showModalEvent) {
showModalEvent.setParams({
"recordId" : s["Id"],
"sObjectName" : objectName,
"modalHeaderTitle" : title
});
showModalEvent.fire();
}
Application Event 'ShowModalEvent' is supposed to be fired every time the link (column data) is clicked. But here, Event is working only for the first time and throwing below error for the second try.
ERROR : Assertion Failed!: Event.setParams(): cannot modify all params in an event that has already been fired. : false
Please advise.