Skip to content
This repository

Support for plugin static files #304

enginous opened this Issue · 4 comments

2 participants

Fred Jonsson Aymeric Augustin
Fred Jonsson

I'm working on a plugin that tracks HTTP requests done with the requests library. For a better user experience, I will have to write some plugin-specific JavaScript code.

I tried adding some inline code to do this (although I don't think that's optimal in the longer term and it won't allow me to bundle icons.) However, it seems that I can't interface with jQuery from my panel template ($ and jQuery aren't available in the namespace).

Is there a way to interface with jQuery and bundle custom scripts with the code as it stands? If not, perhaps we could devise an extension mechanism allowing plugins to carry their own static files. Have you thought about this?

Aymeric Augustin

There's a bit more to this ticket than what the description says :)

Panel-specific JavaScript code should be moved out of toolbar.js into per-panel JavaScript files. These files should be managed with Django's static files infrastructure and included in each panel's template. That will make it easy to run these scripts only after the panel content has been loaded and get rid of live calls which are deprecated in jQuery.

To make this work, we'll have to figure out why jQuery isn't accessible in the global namespace. The situation is quite different after #440.

If we can do this for the built-in panels, it should work just as well for third-party panels.

PS: please submit a pull request to get listed on!

Aymeric Augustin

I've made some progress on splitting panel-specific JavaScript into separate files. I don't know how do deal with JavaScript that is shared by two or three panels. Per-panel JavaScript code doesn't have access to the djdt object since we implemented AMD.

Aymeric Augustin

Currently several panels have their own separate JavaScript.

Now, we could define and document the toolbar JS API.

Aymeric Augustin

This ticket is resolved, I've filed #484 for the task described in my previous comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.