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)

zayno lane
  • 49
  • 6

1 Answers1

0

assuming that u have loaded all jquery ui libraries

then

$(function() {
   $("tr").draggable();
});
Dan Sto Domingo
  • 64
  • 1
  • 11