mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
740 stars 55 forks source link

jQuery import #91

Closed JanPalasek closed 4 months ago

JanPalasek commented 1 year ago

Hi,

I try to integrate your awesome package into Pretty Jupyter. I noticed that itables loads the jQuery without a possibility to overload this settings. This is a bit problematic for me because in the exported HTML file I use another jQuery, which is overwritten by this import. I hotfixed it with jQuery.noConflict() for now, however a better solution is needed.

Some possible solutions that occur to me:

I would like also to ask if there is a reliable way to detect whether the jQuery was imported. I hacked some selector ($(".output_subarea.output_javascript"), but i don't know if this will hold in future releases. Some IDd element would be nice, but I didn't find any.

mwouts commented 1 year ago

Hi @JanPalasek , thanks for reporting this. Could you please confirm which version of itables you use, and also if you use the connected or the offline mode?

In the latest release (1.1.3), in the connected mode (the default), we import jQuery in a script with type "module", cf. this code: https://github.com/mwouts/itables/blob/30f2079e9d3df9f02143bc65247a21b382359504/itables/html/datatables_template_connected.html#L6-L8

At the moment we cannot import jQuery as an ES module but when jQuery==4.0.0 becomes available we should be able to do so, and I expect this will allow us to get rid of the global variable $.

JanPalasek commented 1 year ago

Hello, thank you for such a quick answer. I also use jQuery==3.6.0. It throws errors both with connected=True and False. Here's the page it fails on.

Playground.zip

This code on proper place fixes the issue (before the big Githubissues.

  • Githubissues is a development platform for aggregating issues.