HTML5 attributes and data with defaultContent

HTML5 attributes and data with defaultContent

neilpophamneilpopham Posts: 2Questions: 1Answers: 0

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

  • kthorngrenkthorngren Posts: 21,174Questions: 26Answers: 4,923
    Answer ✓

    You need something more like this:

    <th data-data='null' data-default-content="foo">Actions</th>
    

    As noted in the HTML5 Data Attributes Config Options doc use dashes between words like default and content and it will be converted to camel case. Here is the updated example:
    http://live.datatables.net/fanepezo/2/edit

    Kevin

  • neilpophamneilpopham Posts: 2Questions: 1Answers: 0

    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 of data : value, whereas (I suppose) it's more like the options equivalent of data : { 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!

This discussion has been closed.