1rosehip / jplist

jPList jQuery Data Grid Controls is a flexible jQuery plugin for sorting, pagination and filtering of any HTML structure (DIVs, UL/LI, tables, etc).
http://jplist.com
Other
437 stars 177 forks source link

Get the list empty in one command #214

Closed caneta closed 8 years ago

caneta commented 8 years ago

Trying to get the list empty, I came to the following solution:

do {
  $('#jplist-container').jplist({
    command: 'del',
    commandData: {
      $items: $('.list-item')
    }
  });
} while ($('.list-item').length !== 0);

Basically, I take my visible list items and delete them with the api. But this works only for visible items on the page, not on the hidden ones (hidden by the plugin, for example because filtered or paginated). Having no direct access to the hidden ones, I have to iterate this operation until the list is completely empty. I don't like very much this solution: is there a better way to get the list empty in one command? Thank you.

1rosehip commented 8 years ago

Hi, I've added a possibility to remove all the items through the following API:

            //delete all items from jplist collection
            $('#demo').jplist({
                command: 'empty'
            });

Please download the latest core file: https://raw.githubusercontent.com/no81no/jplist/master/dist/js/jplist.core.min.js

caneta commented 8 years ago

That's exactly what I were looking for, thanks!

1rosehip commented 8 years ago

You're welcome 👍