以下代码适用于IE以外的所有浏览器。我得到“对象不支持属性或方法'绑定'”错误。
var FilteredArray = (gAssessorsInfoArray.filter(ApplyFilters.bind(GetFilters(gServiceInfoArray[0].ServiceName, $("#YearsOfExperienceDropDown").val(), $("#P104DropDown").val(), GeographicalLocationArray, SubSpecialtiesArray, LanguagesSpokenArray))));
我的HTML包含:
<script src="/files/404048/f93304/jquery-1.7.2.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script src="/files/404048/f96289/jquery.multiselect.js"></script>
<script src="/files/404048/f96289/jquery.multiselect.filter.js"></script>
<script src="/files/404048/f96289/prettify.js"></script>
<script src="/files/404048/94413/jquery.tipTip.js"></script>
<script src="/files/404048/94414/jquery.tipTip.minified.js"></script>
我的ApplyFilters
功能:
function ApplyFilters(Item) {
var i;
for(var i = 0; i < this.length; i += 1)
{
if(!this[i](Item))
return false;
}
return true;
}
function GetFilters(ServiceName, YearsOfExperience, P104, GeographicalLocation, SubSpecialties, LanguagesSpoken) {
var Filters = [];
if (ServiceName) {
Filters.push(function (Item) {
return (Item.AvailableForRegular.indexOf(ServiceName) > -1 || Item.AvailableForCAT.indexOf(ServiceName) > -1);
});
}
if (YearsOfExperience != '') {
Filters.push(function (Item) {
return Item.YearsOfExperience === YearsOfExperience;
});
}
if (P104 != '') {
Filters.push(function (Item) {
return Item.P104 === P104;
});
}
if (GeographicalLocation != '') {
Filters.push(function (Item) {
var FoundCounter = 0;
for (var i = 0; i < GeographicalLocation.length; i++) {
if (Item.GeographicalLocation.indexOf(GeographicalLocation[i]) > -1)
FoundCounter++;
}
if(GeographicalLocation.length == FoundCounter)
return true;
else
return false;
});
}
if (SubSpecialties != '') {
Filters.push(function (Item) {
var FoundCounter = 0;
for (var i = 0; i < SubSpecialties.length; i++) {
if(Item.SubSpecialties.indexOf(SubSpecialties[i]) > -1)
FoundCounter++;
}
if (SubSpecialties.length == FoundCounter)
return true;
else
return false;
});
}
if(LanguagesSpoken != '') {
Filters.push(function (Item) {
var FoundCounter = 0;
for (var i = 0; i < LanguagesSpoken.length; i++) {
if (Item.LanguagesSpoken.indexOf(LanguagesSpoken[i]) > -1)
FoundCounter++;
}
if (LanguagesSpoken.length == FoundCounter)
return true;
else
return false;
});
}
return Filters;
}