gajus/wholly

Add row selector

Open

#10 geöffnet am 21. Jan. 2020

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (29 Forks)github user discovery
bughelp wanted

Repository-Metriken

Stars
 (201 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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

Contributor Guide