Question:
I need to create list of sObjects in Javascript.
Let's assume accountWrapperList is a list of (Account + checkbox) defined in controller. You can access this list in your javascript if you use it like this:
var records = '{!accountWrapperList }';
However, this would be a string representation, not list representation.
To convert it into list, you will need to do something like this:
var records = new Array();
<apex:repeat value="{!accountWrapperList}" var="acc">
records.push('{!acc}');
</apex:repeat>
console.log(records);
You will see that records is now a list of sObjects.
Now coming to problem: You can access this list like this - console.log(records[0]); -- Since its a list.
BUT you cant access the list like this - returns "undefined".
console.log(records[0].check);
Despite the fact that "check" is a valid variable that can easily be seen in the console. Have tried many things, but its not working. Can anyone plz suggest?