timeglider/jquery_widget — Issue #34: Displaying multiple timelines on load
Author: jenSadler
Created: 2012-02-02 20:48:06+00:00
State: open

I would like to use a JSON file to display several timelines. Currently the timelines load but do not display automatically. The user must click the menu button and select the timelines individually to display them.

I've looked into the code and I think I've found where the change needs to be made. It's in the setInitialTimelines function in the TG_Mediator.js file. Instead of getting the initial_timeline_id, it should go through all of the timelines in the timelineCollection , get their ids and send them to the MED.toggleTimeline(tid) function.

The problem I'm having is that I don't know how to extract the timeline ids from the individual timelines. I've been trying to just get it in an alert, using this code(I provided the whole function for context):

```javascript
setInitialTimelines : function () {

var me = this;

var tc=me.timelineCollection;
alert(tc.length); //this alert produces the correct number of elements in the timelineCollection

//needs fixing
$.each(tc, function(index, value) {
alert(value.id); //this crashes the program , the rest of the code is just what was there before
});

var tid = this.initial_timeline_id || this.sole_timeline_id;

// !AUTH
if (timeglider.mode == "authoring") {
this.setZoomLevel(40);
} else if (tid) {
// we need to wait just a bit...
// !TODO What is timeout for??
setTimeout(function () { MED.toggleTimeline(tid); }, 500);
} else {
this.setZoomLevel(40);
}

},
```

This is marked as a TODO, so If anyone could help me with it I would be much obliged. I've tried just about every combination I can think of to get the timeline ID.