1

I have a javascript file which outputs a table with some items on the fly, and i want to make them sortable by dragging and dropping them to another order.

i have looked up the JQuery UI library but i can't find how to apply the library to my app.

  static addBookToList(book){
    const list = document.querySelector('.book-list');
    const row = document.createElement('tr');
    row.innerHTML = `
    <td>${book.title}</td>
    <td>${book.author}</td>
    <td>${book.isbn}</td>
    <td><a href="#" class="btn btn-danger btn-med delete">x</a></td>
   `;


   list.appendChild(row);
 }

this will add a table of books to a list (which i want to be sortable)

2
  • 1
    Well, what have you tried so far? It doesn't look like you've attempted to use JQuery UI at all yet. Commented Jan 17, 2019 at 2:49
  • you can read sortable with html tables Commented Jan 17, 2019 at 3:04

1 Answer 1

0

assuming that u have loaded all jquery ui libraries

then

$(function() {
   $("tr").draggable();
});
Sign up to request clarification or add additional context in comments.

1 Comment

That just allows you to drag it around the page. This won't snap, sort or anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.