Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Swapy within a HTML table #115

Open
isoaxe opened this issue Jan 14, 2025 · 0 comments
Open

Use Swapy within a HTML table #115

isoaxe opened this issue Jan 14, 2025 · 0 comments

Comments

@isoaxe
Copy link

isoaxe commented Jan 14, 2025

Is it possible to use Swapy within a HTML table structure if the desired functionality is to drag and drop table rows?

A table has the following structure:

    <table>
        <thead>
            <tr>
                <th>Name</th>
                <th>Age</th>
                <th>City</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>John Doe</td>
                <td>30</td>
                <td>New York</td>
            </tr>
            <tr>
                <td>Jane Smith</td>
                <td>25</td>
                <td>Munich</td>
            </tr>
            <tr>
                <td>Mike Johnson</td>
                <td>35</td>
                <td>Lille</td>
            </tr>
        </tbody>
    </table>

The problem is that Swapy requires the nesting of the element with the data-swapy-item attribute within an element that has the data-swapy-slot attribute. See below from the docs.

<div class="container">
  <div class="section-1" data-swapy-slot="foo">
    <div class="content-a" data-swapy-item="a">
      <!-- Your content for content-a goes here -->
    </div>
  </div>

  <div class="section-2" data-swapy-slot="bar">
    <div class="content-b" data-swapy-item="b">
      <!-- Your content for content-b goes here -->
    </div>
  </div>

  <div class="section-3" data-swapy-slot="baz">
    <div class="content-c" data-swapy-item="c">
      <!-- Your content for content-c goes here -->
    </div>
  </div>
</div>

This does not seem possible to achieve with a table. It requires that <td> be a direct decendent of <tr> and <tr> be a direct decendent of <tbody>.

Is there any workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant