0

I have a function that gets a list of vehicles in an asp.net page

 function GetVehicleCounts(totalVehicles, vehiclesInDepot, vehiclesInFilter,         vehiclesInKnownLocations, vehiclesInUnknownLocations, vehiclesNotInDepot)
{
vehiclesInDepot.value = 0;
vehiclesInFilter.value = 0;
vehiclesInKnownLocations.value = 0;
vehiclesInUnknownLocations.value = 0;
vehiclesNotInDepot.value = 0;
var listofVehicles;
var count = 0;

for (var k in vehicles_dm) {
    vehiclesInDepot.value++;

    if (vehicles_dm[k].IsInFilter) {
        vehiclesInFilter.value++;
    }

    if (vehicles_dm[k].CurrentFeatureType == 11) {
        vehiclesInUnknownLocations.value++;            
    }
    else {
        vehiclesInKnownLocations.value++;
    }
}

if (vehicles_dm != null) {
    vehiclesNotInDepot.value = totalVehicles - vehicles_dm.length;
}
}

However, when I add Mootools to the page I run into the problem of Mootools adding all the function calls to the results. This ends up getting repeated for any function that is similar. Any ideas for correcting?

I don't have a choice about using Mootools and the existing page is done in jQuery.

4

1 回答 1

0

我找到了答案!

'for..in 不适用于数组迭代。它遍历对象的所有非内置属性。由于 MooTools 为 Array 原型添加了更多功能,因此它们现在也是数组属性。请参阅此https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Statements/For...in

只需使用基本的 for 循环进行数组迭代。

使用包含 MooTools 的 for..in 的 Javascript 数组迭代

于 2012-11-28T18:32:53.253 回答