cos-archives / hgrid

[UNMAINTAINED] A Javascript-based hierarchical grid that can be used to manage and organize file/folder-like data
Apache License 2.0
23 stars 14 forks source link

Allow additional HTML attributes to be added to rendered buttons #103

Closed sloria closed 10 years ago

sloria commented 10 years ago

Motivated by CenterForOpenScience/osf#978:

It would be nice to be able to add additional attributes to the markup rendered by HGrid.Fmt.button. The use case in the issue above involves adding data-* attributes in order to apply tooltips to the buttons.

I propose the following API:

var buttonDef = {
  text: 'Some text',
  action: 'download',
  cssClass: 'btn btn-primary',
  // A new property that allows adding extra attributes
  attributes: 'data-toggle="tooltip" data-original-title="Download"'
}

HGrid.Fmt.button(buttonDef)
// => <button data-hg-action="download" 
//       class="btn btn-primary" data-toggle="tooltip" data-original-title="Download">
//           Some text
//      </button>
sloria commented 10 years ago

This has been added in 0.2.6.