samedi 1 octobre 2016

jQuery css on hidden elements

In have an emberjs addon which is a table that has hidden columns.
On that table I fix the table head (and left columns) via css-position and top.

    // Set table head fixed
    function fixHead () {
        console.log('tableFixer: fixHead()');
        var thead = Ember.$(settings.table).find("thead");
        var cells = thead.find("tr > *");

        cells.css({
            'position' : 'relative',
            'background' : '#ff0000',
        });
        console.log(cells); // in here I see ALL the cells, also the hidden ones
    }

I show that hidden column with an ember action.

    expandChildColumn: function(column, sourceIndex) {
        this.get('columns')[sourceIndex+1].set('visible',true);
    },

All fine til there, the "child"-column gets displayed, the th of the primaly shown columns are fixed.

But my problem is, that it seems, that jquery's css-mothod doesn't apply to hidden elements.
So the newly shown column is not fixed.
Neither position nor background gets applied.
I have not found anything about that in the docs.

Is there any special parameter to make css be applied to hidden elements?

Based on this question I'm about to think, that I have to show that column first, set css and hide it again: jQuery: Get height of hidden element in jQuery




Aucun commentaire:

Enregistrer un commentaire