HTML5 attributes and data with defaultContent
HTML5 attributes and data with defaultContent
I want to do as much set up using HTML data attributes as possible.
I need to have a column that will show a link to display a popup menu.
In Javascript I'd use: { data: null, defaultContent: 'my html' }
The following doesn't seem to work for data attributes: <th data-data='{"data":null,"defaultContent":"my html"}'>
Is there any way I can do this? Can you do any set-up on a static field using the data-data
attribute?
http://live.datatables.net/fanepezo/1/edit
Many thanks.
This question has an accepted answers - jump to answer
Answers
You need something more like this:
As noted in the HTML5 Data Attributes Config Options doc use dashes between words like
default
andcontent
and it will be converted to camel case. Here is the updated example:http://live.datatables.net/fanepezo/2/edit
Kevin
Kevin,
Many thanks for the response; I can't believe that I didn't spot that.
I guess I was thinking
data-data
was the options equivalent ofdata : value
, whereas (I suppose) it's more like the options equivalent ofdata : { data : value }
.For the record, I discovered that this also works in the
table
tag:data-column-defs='[{"data":null,"defaultContent":"my html","targets":-1}]'
Although semantically it's not nearly as nice.
Thanks again!