The following function gives the error "Syntax Error: invalid property id" when pasted into the online version of JavaScript Lint. As far as I know, any string is a valid property in a JavaScript object. BTW, I did try quoting the string 'id' and it didn't make any difference. I'm using Firefox 15.0.1 in case that's relevant. In the full JavaScript file I was trying to debug, when this error came up, a later, true syntax error was not found:
<BBCode>
function populateStudents($listelem, lStudents) {
// -- Clear everything but the list divider
$listelem.html("<li data-role='list-divider'>Students:</li>");
// -- Fill in the list of students
for (var i=0; i<lStudents.length; ++i) {
var hStu = lStudents_;
var stuID = hStu.ID;
var ident = hStu.StudentIdent;
var nLogs = hStu.lServiceLogs ? hStu.lServiceLogs.length : 0;
// console.log(ident + ", " + nLogs + " logs");
The following function gives the error "Syntax Error: invalid property id" when pasted into the online version of JavaScript Lint. As far as I know, any string is a valid property in a JavaScript object. BTW, I did try quoting the string 'id' and it didn't make any difference. I'm using Firefox 15.0.1 in case that's relevant. In the full JavaScript file I was trying to debug, when this error came up, a later, true syntax error was not found:
<BBCode>
function populateStudents($listelem, lStudents) {
// -- Clear everything but the list divider
$listelem.html("<li data-role='list-divider'>Students:</li>");
// -- Fill in the list of students
for (var i=0; i<lStudents.length; ++i) {
var hStu = lStudents_;
var stuID = hStu.ID;
var ident = hStu.StudentIdent;
var nLogs = hStu.lServiceLogs ? hStu.lServiceLogs.length : 0;
// console.log(ident + ", " + nLogs + " logs");
var $li = element('li',
,
,
[ 'span', { class: 'ui-li-count', id: 'count'+stuID },
nLogs ? String(nLogs) : '0' ]
);
$listelem.append($li);
}
} /* populateStudents */
</BBCode>_
The issue is with the class property. Change it to:
See http://stackoverflow.com/questions/7524618/why-is-class-a-reserved-word-in-javascript