Join two <h:datatable> with jQuery without losing records after update

Asked

Viewed 204 times

1

I have two datatables, the first one loads 5 records when loading the page and the second one is hidden and empty.

Whenever the scroll reaches the bottom of the page I go in the database, I load 5 more records and fill in the arraylist of the second datatable and then with jQuery I give an append of these records from the second table to the first table:

x = $(#segundaTabela);
$(x).children().children().each(function(){
    $(this).clone().appendTo($('.primeiraTabela').children());
    });

Everything works normal, however I noticed that the ajax requests of the records of the second table stop working when I give more an update on it.

You can fix it?

I’m doing this just to make the loading of the data more dynamic without getting this refresh in table 1, IE, I always load in the second hidden table and then with jQuery clono the records in the first, but if I update the second, even records that have been cloned stop working ajax requests.

Could someone help me ?

  • Welcome to Sopt @Marcus Vinicius. Instead of creating a new question you’d better edit the question. I say this because there is another question of yours here on the site with the same title. http://answall.com/questions/100604/junta-duas-hdatatable-com-jquery-sem-perder-os-registros-ap%C3%B3s-o-update-nas-t

  • Marcus, welcome to [en.so]! I understand what you’re doing and what you want, but you haven’t posted any relevant code (like the table code or what loads the logs when the page scrolls), so it’s hard to guess what might be going on. There is an error in the browser’s Javascript console?

  • Anyway, it seems to me that using JSF components in this way is a potential risk. JSF components are usually stateful, i.e., they depend on the state on the server associated with them. In this case, adding the rows to a client-side table will cause any action associated with these lines to crash. Not to mention you’re interfering with the logic of the Prime Faces components. The behavior of a component that has the structure altered externally is unpredictable and may be the cause of Ajax to stop working. Tip: use a normal table.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.