Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Fixed Timeline.setGroups for Array #2529

Merged
merged 1 commit into from
Jan 3, 2017
Merged

Fixed Timeline.setGroups for Array #2529

merged 1 commit into from
Jan 3, 2017

Conversation

lewisjb
Copy link
Contributor

@lewisjb lewisjb commented Jan 3, 2017

Quote from docs: "groups can be an Array with Objects, a DataSet (offering 2 way data binding), or a DataView (offering 1 way data binding)".

However, in #2315 the array support was broken.

The specific change can be seen by comparing develop to master

The problem is groups.filter(filter), because filter is:

var filter = {
  filter : function(group){
    return group.visible !== false;
  }
}

groups should be an Array, so groups.filter is expecting a function, but is given an object. This results in Uncaught TypeError: #<Object> is not a function (to test for yourself just put [].filter({}) in your development console).

So I changed filter to be the function, and pass in {filter: filter} to DataView. I felt this was a cleaner solution than passing in filter.filter to groups.filter because the function is the shared information.

@yotamberk yotamberk merged commit d3d1dc7 into almende:develop Jan 3, 2017
@lewisjb lewisjb deleted the fix-set-groups-array branch January 4, 2017 00:52
@mojoaxel mojoaxel added this to the Minor Release v4.18 milestone Jan 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants