diff --git a/docs/timeline/index.html b/docs/timeline/index.html
index 70f747be..f32ac2a2 100644
--- a/docs/timeline/index.html
+++ b/docs/timeline/index.html
@@ -648,7 +648,7 @@ function (option, path) {
groupTemplate |
function |
none |
- A template function used to generate the contents of the groups. The function is called by the Timeline with a groups data as argument, and must return HTML code as result. When the option groupTemplate is specified, the groups do not need to have a field content . See section Templates for a detailed explanation. |
+ A template function used to generate the contents of the groups. The function is called by the Timeline with a groups data as the first argument and the group element as the second, and must return HTML code as result. When the option groupTemplate is specified, the groups do not need to have a field content . See section Templates for a detailed explanation. |
@@ -978,7 +978,7 @@ function (option, path) {
template |
function |
none |
- A template function used to generate the contents of the items. The function is called by the Timeline with an items data as argument, and must return HTML code as result. When the option template is specified, the items do not need to have a field content . See section Templates for a detailed explanation. |
+ A template function used to generate the contents of the items. The function is called by the Timeline with an items data as the first argument and the item element as the second, and must return HTML code as result. When the option template is specified, the items do not need to have a field content . See section Templates for a detailed explanation. |
@@ -1630,6 +1630,17 @@ var template = Handlebars.compile(source);
};
+React templates
+
+You can use a React component for the templates by rendering them to the templates' element directly:
+
+
+ template: function (item, element) {
+ return ReactDOM.render(<b>{item.content}</b>, element);
+ },
+
+
+
Multiple templates
In order to support multiple templates, the template handler can be extended to switch between different templates, depending on a specific item property:
diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js
index 3d0d0e82..3302c67e 100644
--- a/lib/timeline/component/Group.js
+++ b/lib/timeline/component/Group.js
@@ -88,7 +88,7 @@ Group.prototype.setData = function(data) {
// update contents
var content;
if (this.itemSet.options && this.itemSet.options.groupTemplate) {
- content = this.itemSet.options.groupTemplate(data);
+ content = this.itemSet.options.groupTemplate(data, this.dom.inner);
}
else {
content = data && data.content;
diff --git a/lib/timeline/component/item/Item.js b/lib/timeline/component/item/Item.js
index ea5c7cbb..743e5944 100644
--- a/lib/timeline/component/item/Item.js
+++ b/lib/timeline/component/item/Item.js
@@ -190,7 +190,7 @@ Item.prototype._updateContents = function (element) {
var content;
if (this.options.template) {
var itemData = this.parent.itemSet.itemsData.get(this.id); // get a clone of the data from the dataset
- content = this.options.template(itemData);
+ content = this.options.template(itemData, element);
}
else {
content = this.data.content;