My code looks like this:
$.extend($.fn.dataTableExt.afnSortData, {
'dom-text': function (oSettings, iColumn) {
var aData = [];
$('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
aData.push(this.value);
});
return aData;
},
'dom-data-rk': function (oSettings, iColumn) {
var aData = [];
$('td:eq(' + iColumn + ')', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
aData.push($(this).attr('data-rk'));
});
return aData;
}
});
I used JSLint and it came up with an error:
Warning 21 JS Lint: Unexpected dangling '_' in '_fnGetTrNodes'.
Can someone explain what this means? I don't understand the error message at all :-(
My code looks like this:
$.extend($.fn.dataTableExt.afnSortData, {
'dom-text': function (oSettings, iColumn) {
var aData = [];
$('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
aData.push(this.value);
});
return aData;
},
'dom-data-rk': function (oSettings, iColumn) {
var aData = [];
$('td:eq(' + iColumn + ')', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
aData.push($(this).attr('data-rk'));
});
return aData;
}
});
I used JSLint and it came up with an error:
Warning 21 JS Lint: Unexpected dangling '_' in '_fnGetTrNodes'.
Can someone explain what this means? I don't understand the error message at all :-(
Share Improve this question edited Sep 28, 2012 at 12:55 James Allardice 166k22 gold badges334 silver badges315 bronze badges asked Sep 28, 2012 at 12:37 Alan2Alan2 24.7k86 gold badges276 silver badges481 bronze badges4 Answers
Reset to default 4JSLint simply doesn't like identifiers to begin with an underscore character. Change the identifier and the warning will go away, or add the following directive to the top of the file:
/*jslint nomen: true */
The reason it doesn't like them is that people often use it to indicate a "private" variable, but doesn't actually change the behaviour of the variable.
Do not use _ (underbar) as the first character of a name. It is sometimes used to indicate privacy, but it does not actually provide privacy. If privacy is important, use the forms that provide private members. Avoid conventions that demonstrate a lack of petence.
more about code conventions used by JSLint here
You can simply set "tolerate dangling _ in identifiers" to true to ignore this error.
Well, JSlint doesn't like a variable name that begins with an underscore (_
).
It is better to use JShint. instead of JSlint. It's a fork of JSlint and provide you more options of configuration and doesn't show stupid errors like this. https://stackoverflow./a/10763615/1149495