diff --git a/HISTORY.md b/HISTORY.md index 775135e1..63236e0b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,9 +6,13 @@ http://visjs.org ### Timeline -- items can be dragged and removed. +- Items can be dragged and removed. - Implemented options `selectable`, `editable`. -- added events when dragging the custom time bar. +- Added events when dragging the custom time bar. + +### DataSet + +- Renamed functions `subscribe` and `unsubscribe` to `on` and `off` respectively. ## 2014-01-31, version 0.4.0 diff --git a/docs/dataset.html b/docs/dataset.html index e6e8310b..cbb2ec8f 100644 --- a/docs/dataset.html +++ b/docs/dataset.html @@ -62,8 +62,8 @@ data.add([ ]); // subscribe to any change in the DataSet -data.subscribe('*', function (event, params, senderId) { - console.log('event', event, params); +data.on('*', function (event, properties, senderId) { + console.log('event', event, properties); }); // update an existing item @@ -545,8 +545,8 @@ var items = data.get({

One can subscribe on changes in a DataSet. - A subscription can be created using the method subscribe, - and removed with unsubscribe. + A subscription can be created using the method on, + and removed with off.

@@ -554,8 +554,8 @@ var items = data.get({
 var data = new vis.DataSet();
 
 // subscribe to any change in the DataSet
-data.subscribe('*', function (event, params, senderId) {
-  console.log('event:', event, 'params:', params, 'senderId:', senderId);
+data.on('*', function (event, properties, senderId) {
+  console.log('event:', event, 'properties:', properties, 'senderId:', senderId);
 });
 
 // add an item
@@ -565,14 +565,14 @@ data.remove(1);                                 // triggers an 'remove' event
 
-

Subscribe

+

On

Subscribe to an event.

Syntax: -
DataSet.subscribe(event, callback)
+
DataSet.on(event, callback)
Where: -

Unsubscribe

+

Off

Unsubscribe from an event.

Syntax: -
DataSet.unsubscribe(event, callback)
+
DataSet.off(event, callback)
Where event and callback correspond with the -parameters used to subscribe to the event. +parameters used to subscribe to the event.

Events

@@ -650,7 +650,7 @@ parameters used to subscribe to the event.

-function (event, params, senderId) {
+function (event, properties, senderId) {
   // handle the event
 });
 
@@ -674,13 +674,13 @@ function (event, params, senderId) { - params + properties Object | null - Optional parameters providing more information on the event. + Optional properties providing more information on the event. In case of the events add, update, and remove, - params is always an object containing a property + properties is always an object containing a property items, which contains an array with the ids of the affected items. diff --git a/docs/dataview.html b/docs/dataview.html index 1698ffb1..a1fd350f 100644 --- a/docs/dataview.html +++ b/docs/dataview.html @@ -63,8 +63,8 @@ var view = new vis.DataView(data, { }); // subscribe to any change in the DataView -view.subscribe('*', function (event, params, senderId) { - console.log('event', event, params); +view.on('*', function (event, properties, senderId) { + console.log('event', event, properties); }); // update an item in the data set @@ -201,8 +201,8 @@ var view = new vis.DataView({ }); // subscribe to any change in the DataView -view.subscribe('*', function (event, params, senderId) { - console.log('event:', event, 'params:', params, 'senderId:', senderId); +view.on('*', function (event, properties, senderId) { + console.log('event:', event, 'properties:', properties, 'senderId:', senderId); }); // add, update, and remove data in the DataSet... diff --git a/examples/timeline/06_event_listeners.html b/examples/timeline/06_event_listeners.html index 8ea72e1b..e488e930 100644 --- a/examples/timeline/06_event_listeners.html +++ b/examples/timeline/06_event_listeners.html @@ -18,15 +18,22 @@