Browse Source

Write all item fields as data-? attributes on element

If the dataAttributes config option = 'all' then write every field as
data-? attributes on the element.
v3_develop
Dan Turkenkopf 10 years ago
parent
commit
37c4bfbaff
1 changed files with 14 additions and 2 deletions
  1. +14
    -2
      lib/timeline/component/item/Item.js

+ 14
- 2
lib/timeline/component/item/Item.js View File

@ -201,8 +201,20 @@ Item.prototype._updateTitle = function (element) {
*/
Item.prototype._updateDataAttributes = function(element) {
if (this.options.dataAttributes && this.options.dataAttributes.length > 0) {
for (var i = 0; i < this.options.dataAttributes.length; i++) {
var name = this.options.dataAttributes[i];
var attributes = [];
if (Array.isArray(this.options.dataAttributes)) {
attributes = this.options.dataAttributes;
}
else if (this.options.dataAttributes == 'all') {
attributes = Object.keys(this.data);
}
else {
return;
}
for (var i = 0; i < attributes.length; i++) {
var name = attributes[i];
var value = this.data[name];
if (value != null) {

Loading…
Cancel
Save