From 82b773b63f039f1e34f418c638f53eb6de62bded Mon Sep 17 00:00:00 2001 From: Bben <47628473+Bbillyben@users.noreply.github.com> Date: Thu, 17 Nov 2022 23:44:59 +0100 Subject: [PATCH] Panel mixin js load (#393) * Update panel.md Add few words about javascript integration for PanelMixin inhertance * Update panel.md --- docs/extend/plugins/panel.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/extend/plugins/panel.md b/docs/extend/plugins/panel.md index 656f8bb..529018c 100644 --- a/docs/extend/plugins/panel.md +++ b/docs/extend/plugins/panel.md @@ -33,6 +33,25 @@ In this case, the template can then be loaded (from any plugin!) by loading "myp Custom code can be provided which will run when the particular panel is first loaded (by selecting it from the side menu). +To add some javascript code, you can add a reference to a function that will be called when the panel is loaded with the 'javascript' key in the panel description : +``` + { + 'title': "Updates", + 'description': "Latest updates for this part", + 'javascript': 'alert("You just loaded this panel!")', + } +``` + +Or to add a template file that will be renderered as javascript code, from the plugin template folder, whith the 'javascript_template' key in the panel description : + ``` + { + 'title': "Updates", + 'description': "Latest updates for this part", + 'javascript_template': 'pluginTemplatePath/myJavascriptFile.js', + } +``` +note : see convention for template directory above. + ## Example Implementation Refer to the `CustomPanelSample` example class in the `./plugin/samples/integration/` directory, for a fully worked example of how custom UI panels can be implemented.