reference to document is fixed @ loading time, no way to change that.

reference to document is fixed @ loading time, no way to change that.

didiergmdidiergm Posts: 14Questions: 0Answers: 0
edited May 2011 in General
Allan,

Possibly a bug, certainly a limitation (I qualify this by saying a limitation TO ME, as I do not think this is a general use case) : the reference to the document to which the datatable belongs is fixed when the DT plugin is loaded, subsequent datatable() call thus reference the originating document, not the document the DT belongs to.

In short this prevents to use a datatable in an inframe, where I did not want to load jQuery, datatable and each and every plugin I use. Using the context parameter of the jQuery call works fine to locate the table in the iFrame from the parent window, but during the datatable() call various elements are created, in the context of the original document, not the iFrame one and I very rapidly get a 'DOM 4 uncaught exception' meaning that DT is trying to append elements not belonging to the same document.

How difficult would it be to add a setup parameter ? my low understanding of how plugins work do not allow me to test it myself. Any explanation to get my started at trying this would be fantastic; if it work I could then submit a patch to you.

If it is a no-no, I'll have to resort to loading the same scripts for each iFrame, but I really hate to do this.

Thanks for your input

Didier

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    An interesting situation, and not one I had considered I must admit. There are a number of references to 'document' in DataTables (55 of them apparently in 1.8 beta 3) which could possibly be replaced with a reference to the document element that you actually want to use.

    This is probably a bit of an edge case I think, so not something that I'll put into the DataTables core at this time - but of course you could always fork the project and replace those references with a context switching variable.

    Allan
  • didiergmdidiergm Posts: 14Questions: 0Answers: 0
    Allan, thanks a lot for your answer. Funnily enough I managed to implement this w/o much issues nor much changes. (one more option in the aoInit structure) and made sure to carry on referencing the normal document for routines linked to cookie handling.

    The only issue I have now is to allocate events from the parent window, (e.g. rowclick) as I don't seem to find the correct syntax. I'll leave it aside for the moment as time presses, but will get back to it.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Cool - good to hear you got it going. I'll keep this in mind moving forward with DataTables incase it comes up again and proves to be used a little bit more.

    Regards,
    Allan
This discussion has been closed.