I have upgraded to jQuery 1.10.2 in my application, and I am getting an error in my code (in $.each
).
'invalid 'in' operand e' .
This error occured after upgrading jQuery. In 'this._currentFilterbarValue
', there is a string value which I need to check against some condition.
_CheckForSkipInput: function () {
var IsSkip = false;
if (this._currentFilterColumn.type == "String") {
var stringSkipInput = new Array(">", "<", "=", "!");
$.each(this._currentFilterbarValue, function (index, value) {
if (jQuery.inArray(value, stringSkipInput) != -1)
IsSkip = true;
});
}
return IsSkip;
},
I have upgraded to jQuery 1.10.2 in my application, and I am getting an error in my code (in $.each
).
'invalid 'in' operand e' .
This error occured after upgrading jQuery. In 'this._currentFilterbarValue
', there is a string value which I need to check against some condition.
_CheckForSkipInput: function () {
var IsSkip = false;
if (this._currentFilterColumn.type == "String") {
var stringSkipInput = new Array(">", "<", "=", "!");
$.each(this._currentFilterbarValue, function (index, value) {
if (jQuery.inArray(value, stringSkipInput) != -1)
IsSkip = true;
});
}
return IsSkip;
},
Share
Improve this question
edited Dec 11, 2013 at 6:58
Pranav 웃
8,4676 gold badges40 silver badges48 bronze badges
asked Dec 11, 2013 at 6:32
RGRRGR
1,5712 gold badges23 silver badges37 bronze badges
1
-
what type of
_currentFilterbarValue
? – Grundy Commented Dec 11, 2013 at 6:37
1 Answer
Reset to default 4What you are trying is to iterate through the characters in this._currentFilterbarValue
(which is a string) and therefore jQuery.each()
is failing
The
$.each()
function can be used to iterate over any collection, whether it is an object or an array.
So try like
var IsSkip = false;
if (this._currentFilterColumn.type == "String") {
var stringSkipInput = new Array(">", "<", "=", "!");
for (var i = 0; i < s.length; i++) {
if (jQuery.inArray(s[i], stringSkipInput) != -1) IsSkip = true;
}
}
return IsSkip;
},
Another approach,
Converting your string this._currentFilterColumn
to character array
and then iterating using $.each()
var arr = this._currentFilterColumn.split(""); //Converting a string to char array
$.each(arr, function (index, value) { //Now iterate the character array
if (jQuery.inArray(value, stringSkipInput) != -1) IsSkip = true;
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744789025a4593801.html
评论列表(0条)