I have created a dynamically generated grid of records using HTML and Java on the VF page. Now I need to allow editing of the record. For the edit functionality, I have created a javascript function that is being called by setting the onclick attribute of the EditLink to the Javascript function. I have tried to pass the record Id as a parameter to the JS function that does a remote action call to a function in controller that does a SOQL query to search and return the record. From the functionality point of view, the pop up opens but is blank and a VF error of list is empty is displayed. The issue is that the Id is not being passed through to the JS function. The pseudocode is as under:
Setting the Parameter:
//EditLink test
var TestEdit ='';
TestEdit.innerHTML = mapQ[record.AttendeeId].strId;
console.log ("TestEdit: ");
console.log (TestEdit); //This is being returned as blank
//Setting EditLink variable properties
EditLink = document.createElement('a');
EditLink.setAttribute('HREF', "javascript:PopEdit(TestEdit)");
EditLink.setAttribute('onclick', PopEdit(TestEdit));
EditLink.innerHTML = "Edit";
Edit popup
function PopEdit(TestEdit){
console.log ('in PopEdit function the id is:');
console.log (TestEdit); //appearing blank
jQuery("#EditContact").modal();
var UpdateId = Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.ControllerC.UpdateRecord}',
TestEdit,handleUpdateResultresponse);
function handleUpdateResultresponse(result, event){
if (event.status)
{console.log ('The update id is:');
console.log (UpdateId);
}
The think the issue is that the jQuery statement should be in the if(event.status) clause. However, if that was the case then the Console.log should've displayed the id (please refer statements where it indicates a blank value was returned). Please share what do you think needs to be fixed here. Thanks