Code not working
-
Hi. I’m grateful for Code Embed, but having trouble getting it to work.
I wonder if this is the problem: I’ve looked in my page source, and I find that html elements are being writing inside my script tags. Here’s what I found:
<p><!-- Code Embed v2.3.2 --><br /> <script type="module"> import {Inspector, Runtime} from "https://unpkg.com/@observablehq/[email protected]?module"; import notebook from "https://api.observablehq.com/@ralphlombreglia/[email protected]?v=3";</p> <p> const renders = { "chart": "#chart", };</p> <p> Runtime.load(notebook, (variable) => { const selector = renders[variable.name]; if (selector) { return new Inspector(document.querySelector(selector)); } });</p> <p></script><br /> <!-- End of Code Embed output --></p>Is that right?
Here’s the code I put into Code Embed. It works with no problem in a straight HTML page outside WordPress:
<script type="module"> // Load the Observable runtime and inspector. import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js"; // Your notebook, compiled as an ES module. import notebook from "https://api.observablehq.com/@ralphlombreglia/[email protected]?v=3"; // Load the notebook, observing its cells with a default Inspector // that simply renders the value of each cell into the provided DOM node. //new Runtime().module(notebook, Inspector.into(document.body)); // from https://observablehq.com/@observablehq/downloading-and-embedding-notebooks new Runtime().module(notebook, name => { if (name === "chart") { return new Inspector(document.querySelector("#chart")); } }); </script>Thanks.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Code not working’ is closed to new replies.