No, that's what you need to do.
The EventSource fires the onAddMany event.
This is bound in the Band.prototype._onAddMany function to call
this._paintEvents(), which calls .paint() on the eventPainter for that Band.
Make sure that your JSON data matches the expected members for a new Event, and
that you aren't getting any errors adding the evt to the eventSource (e.g.
malformed dates). Also check that your new events are actually within the
visible portion of the timeline. If you add events that are too far away from
the visible timeline, you might not see anything happen when you repaint.
--Mike
On Nov 1, 2011, at 10:03 AM, Alvin Cheung wrote:
> Actually I tried that but that doesn't seem to do the trick (also tried
> eventSource._fire("onAddOne", [evt]). Is there something else that I need to
> do?
>
> On 11/1/2011 9:45 AM, Michael Nosal wrote:
>> Yes, adding events is separate from redrawing the timeline.
>>
>> If you look at sources.js, the last thing the loadXML and loadJSON functions
>> do is:
>>
>> if (added) {
>> this._fire("onAddMany", []);
>> }
>>
>> You can manipulate events (adding, editing and removing) in an EventSource
>> and then trigger the onAddMany event to let the timeline know it should do a
>> re-layout and a repaint.
>>
>> --Mike
>>
>>
>> On Nov 1, 2011, at 8:51 AM, Alvin Cheung wrote:
>>
>>> Hello,
>>>
>>> Apologies if this question is too simple. I'm trying to write code that
>>> dynamically add events to an existing timeline via ajax with this jquery
>>> snippet:
>>>
>>> newData = jQuery.parseJSON(data);
>>> for (var i=0; i< newData.events.length; i++){
>>> var event = newData.events[i];
>>> var evt = new Timeline.DefaultEventSource.Event(event);
>>> eventSource.add(evt);
>>> }
>>>
>>> But the timeline doesn't get redrawn after calling eventSource.add. Do I
>>> need to call something special to get the timeline redraw? I've tried
>>> printing out the contents of evt and it looks good to me.
>>>
>>> Thanks,
>>> Alvin
--
You received this message because you are subscribed to the Google Groups
"SIMILE Widgets" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simile-widgets?hl=en.