Interceptar cuando se agregan nuevas filas a una tabla

Within a legacy application I have a table to which initially only a subset of available rows is displayed in order to fit the current page size. When the user scroll down the div containing the table, automatically new rows are added via javascript.

What I need to do is to be able to intercept cuando these rows are added to the table.
At the beginngin I polled through the setInterval method in order to execute my logic, but unfortunately this interfers with the business logic of the legacy application.

I tried the following code (applied once at the div container and once to the table) without any results:

$(document).ready(function()
{
  $('#myWebGrid1').change(function()
  {
    alert('changed!');
  });
});

I tried also the resize() method, but it does not work either since by scrolling the div size does not change.

preguntado el 08 de noviembre de 11 a las 10:11

what scroll helper thing do you use or have you made? Maybe you could implement some callback when new rows are added? -

Can you post the javascript/jquery code where the addition of rows is defined ? I think you can intercept there, just before creation of the new rows. -

I do not use any scroll helper, this logic and code is part of the legacy aplication. @iTypist: I cannot see the javascript function. I tried with fiddler to get the .js filenames used, since there are plenty of external files imported, but since the web site is over SSL I do not get useful information. That's why I was trying to inject my logic over it. -

2 Respuestas

I think that the only option you have is to use the old livequery plugin which allowed something similar (or you could copy the logic used by that plugin) as you can see from this artículo

respondido 08 nov., 11:14

+ 1 - Thanks for the article, I will try to get some hint from it. - Francesco

Unfortunately there are no events raised when the DOM is changed or amended. The solution here would be to manually raise an event in the code which causes the DOM to be updated, which you can add a listener for somewhere else in your code.

respondido 08 nov., 11:14

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.