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

Can't filter ajax loaded data #144

Closed tchiktchak closed 8 years ago

tchiktchak commented 8 years ago

Hi, i'm using jplist for this website i'm developing and it is great... although, i'm having an issue which is driving me crazy since a few hours... for my own sanity, i have to ask you if you could redirect me to a solution... i've read all i could find on the internet about the subject but i can't seem to find the solution.

The system is based on wordrpress. There is an initial dataset loaded with php, the classical way This is searchable trough a few jplist controls and it works I initiate jplist with jquery like this

$('document').ready(function(){
   var $jipe = $('.main');
   //init jplist first time
   $jipe.jplist({               
    itemsBox: '#results',
    itemPath: '.tile__archive',
    panelPath: '.jplist-panel',
    redrawCallback: function(collection, $dataview, statuses){
    fill();  
   });
  });

But then, i load a new dataset into my results div trough ajax and a new wordpress query and then using the jplist control makes a total mess Reading and looking for a solution, i understood i had to delete the dataset of the jplist instance and add the newly loaded data... i tried in every single way but failed again and again !

My last attempt was adding this in my ajax success function... but it did'nt worked


$(".main").jplist({

            command: 'del'
      ,commandData: {
         $items: $('.tile__archive')  //select your items using jQuery
      }

            });
   alert("deleted");      

    $(".main").jplist({
      command: 'add'
      ,commandData: {
         $items: $('.tile__archive'),  //select your items using jQuery
          index: 0 //if index is omitted -> the items are added to the end of the list
      }
   });
      alert("added");      

If you had a few minutes to help me, i'd appreciate greatly ! Thanks

1rosehip commented 8 years ago

Hi, unfortunately html version of jplist won't work this way, because it requires all the items been loaded before initial jplist call. There are server side versions of jplist, please check them and maybe they will be helpful.

Thanks,

tchiktchak commented 8 years ago

Hello thanks for this answer... it explains my brain melt of yesterday ! Bye !

1rosehip commented 8 years ago

Sorry for that :(