1

I am using fooTable and having problems withh inner content of <td> elements. They all get removed. This wasn't the case in previous version, but v3 removes it. For example if i add a button <td><button class="online">Turn on</button></td> it gets removed, as well as the class of table cell.

How can this be prevented?

Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185
user4675957
  • 233
  • 2
  • 3
  • 12

3 Answers3

4

How about we set at Header Data Parameter

"data-type"="html"

psycobot
  • 39
  • 2
0

For anyone looking to prevent this, the change can be made in footable.js. Change this:

    $create: function(){
        if (this.created) return;
        (this.$el = F.is.jq(this.$el) ? this.$el : $('<td/>'))
            .data('value', this.value)
            .contents().detach().end()
            .append(this.format(this.value));

        this._setClasses(this.$el);
        this._setStyle(this.$el);

        this.$detail = $('<tr/>').addClass(this.row.classes.join(' ')).data('__FooTableCell__', this)
            .append($('<th/>', { text: this.column.title }))
            .append($('<td/>'));

        this.created = true;
    },

to:

$create: function(){
            if (this.created) return;
            (this.$el = F.is.jq(this.$el) ? this.$el : $('<td/>'))
                .data('value', this.value)
                .contents();

            this._setClasses(this.$el);
            this._setStyle(this.$el);

            this.$detail = $('<tr/>').addClass(this.row.classes.join(' ')).data('__FooTableCell__', this)
                .append($('<th/>', { text: this.column.title }))
                .append($('<td/>'));

            this.created = true;
        },

Well, this might not be the best way to handle, but it served my purpose. This leaves unformated content, and keeps links, buttons, classes set...

user4675957
  • 233
  • 2
  • 3
  • 12
0

Adding to @user4675957's excellent contribution: When you use inner HTML, the details (collapsed table) version will show it as text. This is because it is loaded as such.

To prevent this, modify this line in the $create function:

 .append($('<th/>', { text: this.column.title }))

to

.append($('<th/>').append(this.column.title))
Michel
  • 1