gajus/wholly

Add row selector

Open

#10 ouverte le 21 janv. 2020

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)JavaScript (29 forks)github user discovery
bughelp wanted

Métriques du dépôt

Stars
 (201 stars)
Métriques de merge PR
 (Métriques PR en attente)

Description

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)',
    ...
});

Guide contributeur