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)
});
});
Remove searchStr
from the arguments for your filter
function:
var filteredArray = IEG.searchColl.models.filter(function (model) {
console.log(model.get("key") + searchStr);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.