Code block not executing in embedded version

I have a notebook I’m trying to embed, however it’s not fully behaving as expected. The notebook has the following code block that is not firing in the embedded version and I’m trying to understand why:

{
  changeTab();
}

I created a simple Codepen with the embed strategy here. You’ll notice that the console logs nothing in codepen and the swapTabChoice call is not made.

At the core I’m trying to understand why this block does not execute, similarly, there’s a console.log statement console.log('This does not log.'); that does not log so it seems related to top-level cells? And if this is to be expected, how should I approach executing code on what would be the JS equivalent of DOMContentLoaded.

Thanks!

Strange. It works for me, try https://observablehq.com/embed/a4a9bd19b54698c4?cell=*

Here is the output I get:

Looking at your codepen, I see the issue… you are only embedding one cell… try removing the line:
if (name === 'output') {

@Cobus ah good call, appending else { return true; } yields the result I was looking for. Thanks so much for that!

1 Like