Reputation: 5631
I'm trying, without success, to get a String value directly from the pojo sent from my controller to the HTML page, parse it into an array and build an editable grid with it.
The implentation is:
$(document).ready(function() {
var emails = eval(${pojo.resultEmailRecipients});
var list = emails.split(",");
var metadata = [];
metadata.push({ name: "email", label: "EMAIL", datatype: "email", editable: true});
var data = [];
var id = 1;
for (email in list) {
data.push({id: id, values: {"email": email}});
id++;
}
editableGrid = new EditableGrid("DemoGridJsData");
editableGrid.load({"metadata": metadata, "data": data});
editableGrid.renderGrid("table1", "testgrid");
});
Ideally this will he rendered at:
<div id="table1"></div>
But Firebug reports and error getting the object.
SyntaxError: missing ) after argument list
var emails = eval(${pojo.resultEmailRecipients});
What's going on here?
Upvotes: 0
Views: 206
Reputation: 166
the problem is this variable ${pojo.resultEmailRecipients} with eval function, eval expects an expression not a pojo. try to change your code to var emails = pojo.resultEmailRecipients;
Upvotes: 1