gajus/wholly

Add row selector

Open

#10 aperta il 21 gen 2020

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (29 fork)github user discovery
bughelp wanted

Metriche repository

Star
 (201 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

When a table is nested in a cell, selecting cells gives unexpected results. For example:

<table id="main">
    <tr>
        <td>Main Cell</td>
    </tr>
    <tr>
        <td>
            <table id="child">
                <tr>
                    <td>Child cell</td>
                </tr>
            </table>
        </td>
    </tr>
</table>

To be able to distinguish between the rows of the main table and the rows of the nested table, an option can be added to select rows (with tr as default):

Wholly.DEFAULTS = {
    rowSelector: 'tr',
    ...
}

The rows selection is set as:

wholly.indexTable = function (table) {
    var tableIndex = wholly.generateTableMatrix(table),
        rows = table.find(this.options.rowSelector);
    ...
}

And for the example above:

<table id="main">
    <tr>
        <td>Main Cell</td>
    </tr>
    <tr>
        <td>
            <table id="child">
                <tr class="skip">
                    <td>Child cell</td>
                </tr>
            </table>
        </td>
    </tr>
</table>
$('#main')wholly({
    rowSelector: 'tr:not(.skip)',
    ...
});

Guida contributor