Just render the DOM in dynamic creation with JSON

Just render the DOM in dynamic creation with JSON

TizTiz Posts: 4Questions: 0Answers: 0
edited August 2010 in General
Hello,

I use dataTable with JSON dynamic creation, and I would like to apply a function (Jquery contextMenu) in each row of this table (on a particular span in a particular td but nevermind...).

The issue is, if I apply my function after the dataTable() function, only the 5 first rows are concerned (iDisplayLength = 5) because the DOM is not formed.

I found a solution to this problem, but I think it is not optimised at all :
I draw the dable, I use the new function 1.7 fnDestroy(), I apply my function, and redraw the form.

But the JSON dynamic creation has no more interest for optimisation (or less) in this case.

I wonder if it would exist a function that just render my JSON objet into the DOM in order to apply my function, and then draw, without draw it first. (Hope you will understand me ^^).

Thanks for your answers and sorry for my english i'm french ^^

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited August 2010
    Rather than doing this:

    [code]
    $('#example tbody tr td:eq(0)>span').whatever();
    [/code]
    do

    [code]
    $('td:eq(0)>span', oTable.fnGetNodes()).whatever();
    [/code]
    fnGetNodes will get an array of all TR elements in the table which you can then work on.

    Allan
  • TizTiz Posts: 4Questions: 0Answers: 0
    Ok thank you very much for your fast answers !

    I'm going to try that.
This discussion has been closed.