Skip to content

Commit

Permalink
Fix require.js import in jupyter-widgets integration
Browse files Browse the repository at this point in the history
  • Loading branch information
rclement committed Sep 3, 2021
1 parent 1ce352d commit 06a8984
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mknotebooks/templates/custom_markdown.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

{% block header %}
{{ super() }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
(function() {
function addWidgetsRenderer() {
var requireJsScript = document.createElement('script');
requireJsScript.src = 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js';
var mimeElement = document.querySelector('script[type="application/vnd.jupyter.widget-view+json"]');
var scriptElement = document.createElement('script');
var jupyterWidgetsScript = document.createElement('script');
var widgetRendererSrc = 'https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js';
var widgetState;
Expand All @@ -22,8 +24,10 @@
}
} catch(e) {}
scriptElement.src = widgetRendererSrc;
document.body.appendChild(scriptElement);
jupyterWidgetsScript.src = widgetRendererSrc;
document.body.appendChild(requireJsScript);
document.body.appendChild(jupyterWidgetsScript);
}
document.addEventListener('DOMContentLoaded', addWidgetsRenderer);
Expand Down

0 comments on commit 06a8984

Please sign in to comment.