1

How can I access the searchStr variable within the anonymous function within the filter function? Below searchStr prints 0 - n, I guess an iterator for looping through the collection that I am attempting to filter

IEG.vent.on("searchGroups", function (searchStr) {
    if (searchStr) {
        IEG.Router.navigate("search/" + searchStr);
    }
    else {
        IEG.Router.navigate();
    }

    var filteredArray = IEG.searchColl.models.filter(function (model,searchStr) {                
       console.log(model.get("key") + searchStr)
    });
});
4

1 回答 1

4

searchStr从函数的参数中删除filter

var filteredArray = IEG.searchColl.models.filter(function (model) {   
    console.log(model.get("key") + searchStr);
});
于 2013-09-27T18:26:02.123 回答