|
@ -62,8 +62,8 @@ data.add([ |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
// subscribe to any change in the DataSet |
|
|
// 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 |
|
|
// update an existing item |
|
@ -545,8 +545,8 @@ var items = data.get({ |
|
|
|
|
|
|
|
|
<p> |
|
|
<p> |
|
|
One can subscribe on changes in a DataSet. |
|
|
One can subscribe on changes in a DataSet. |
|
|
A subscription can be created using the method <code>subscribe</code>, |
|
|
|
|
|
and removed with <code>unsubscribe</code>. |
|
|
|
|
|
|
|
|
A subscription can be created using the method <code>on</code>, |
|
|
|
|
|
and removed with <code>off</code>. |
|
|
</p> |
|
|
</p> |
|
|
|
|
|
|
|
|
<pre class="prettyprint lang-js"> |
|
|
<pre class="prettyprint lang-js"> |
|
@ -554,8 +554,8 @@ var items = data.get({ |
|
|
var data = new vis.DataSet(); |
|
|
var data = new vis.DataSet(); |
|
|
|
|
|
|
|
|
// subscribe to any change in the 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 |
|
|
// add an item |
|
@ -565,14 +565,14 @@ data.remove(1); // triggers an 'remove' event |
|
|
</pre> |
|
|
</pre> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3 id="Subscribe">Subscribe</h3> |
|
|
|
|
|
|
|
|
<h3 id="On">On</h3> |
|
|
|
|
|
|
|
|
<p> |
|
|
<p> |
|
|
Subscribe to an event. |
|
|
Subscribe to an event. |
|
|
</p> |
|
|
</p> |
|
|
|
|
|
|
|
|
Syntax: |
|
|
Syntax: |
|
|
<pre class="prettyprint lang-js">DataSet.subscribe(event, callback)</pre> |
|
|
|
|
|
|
|
|
<pre class="prettyprint lang-js">DataSet.on(event, callback)</pre> |
|
|
|
|
|
|
|
|
Where: |
|
|
Where: |
|
|
<ul> |
|
|
<ul> |
|
@ -587,17 +587,17 @@ Where: |
|
|
</li> |
|
|
</li> |
|
|
</ul> |
|
|
</ul> |
|
|
|
|
|
|
|
|
<h3 id="Unsubscribe">Unsubscribe</h3> |
|
|
|
|
|
|
|
|
<h3 id="Off">Off</h3> |
|
|
|
|
|
|
|
|
<p> |
|
|
<p> |
|
|
Unsubscribe from an event. |
|
|
Unsubscribe from an event. |
|
|
</p> |
|
|
</p> |
|
|
|
|
|
|
|
|
Syntax: |
|
|
Syntax: |
|
|
<pre class="prettyprint lang-js">DataSet.unsubscribe(event, callback)</pre> |
|
|
|
|
|
|
|
|
<pre class="prettyprint lang-js">DataSet.off(event, callback)</pre> |
|
|
|
|
|
|
|
|
Where <code>event</code> and <code>callback</code> correspond with the |
|
|
Where <code>event</code> and <code>callback</code> correspond with the |
|
|
parameters used to <a href="#Subscribe">subscribe</a> to the event. |
|
|
|
|
|
|
|
|
parameters used to <a href="#On">subscribe</a> to the event. |
|
|
|
|
|
|
|
|
<h3 id="Events">Events</h3> |
|
|
<h3 id="Events">Events</h3> |
|
|
|
|
|
|
|
@ -650,7 +650,7 @@ parameters used to subscribe to the event. |
|
|
</p> |
|
|
</p> |
|
|
|
|
|
|
|
|
<pre class="prettyprint lang-js"> |
|
|
<pre class="prettyprint lang-js"> |
|
|
function (event, params, senderId) { |
|
|
|
|
|
|
|
|
function (event, properties, senderId) { |
|
|
// handle the event |
|
|
// handle the event |
|
|
}); |
|
|
}); |
|
|
</pre> |
|
|
</pre> |
|
@ -674,13 +674,13 @@ function (event, params, senderId) { |
|
|
</td> |
|
|
</td> |
|
|
</tr> |
|
|
</tr> |
|
|
<tr> |
|
|
<tr> |
|
|
<td>params</td> |
|
|
|
|
|
|
|
|
<td>properties</td> |
|
|
<td>Object | null</td> |
|
|
<td>Object | null</td> |
|
|
<td> |
|
|
<td> |
|
|
Optional parameters providing more information on the event. |
|
|
|
|
|
|
|
|
Optional properties providing more information on the event. |
|
|
In case of the events <code>add</code>, |
|
|
In case of the events <code>add</code>, |
|
|
<code>update</code>, and <code>remove</code>, |
|
|
<code>update</code>, and <code>remove</code>, |
|
|
<code>params</code> is always an object containing a property |
|
|
|
|
|
|
|
|
<code>properties</code> is always an object containing a property |
|
|
items, which contains an array with the ids of the affected |
|
|
items, which contains an array with the ids of the affected |
|
|
items. |
|
|
items. |
|
|
</td> |
|
|
</td> |
|
|