Closed zvictor closed 10 years ago
A reference to clarify this issue: jQuery inArray is always returning -1
Nice catch.
Fails the Grunt lint tests though with http://jslinterrors.com/dont-make-functions-within-a-loop
This might be an alternative?
function eventsForResource(resource, events) {
var resourceEvents = [];
var hasResource = function(event) {
if (!event.resources) {
return false;
}
return $.grep(event.resources, function(id) { return id === resource.id; }).length > 0;
}
for (var i = 0; i < events.length; i++) {
if (hasResource(events[i])) {
resourceEvents.push(events[i]);
}
}
return resourceEvents;
}
You are right. I am fixing it right now = )
Done.
Currently, the following example would not show any event.
This pull request allows the showed example to work by removing the strictness of types when associating resources and events.