I think you might do this much more cleanly by d3.select
ing the html
literal and programmatically adding the event listener. Here’s an example:
If you open the notebook (by clicking on its name in the iframe footer), you should notice the following:
- The text of the
html
literal is defined by a string in a separate cell, - the function
f
that converts from decimal to binary is also defined in a separate cell, and - the event is set using
d3.select
, as mentioned above.
As a side note, a friend of mine met Douglas Adams at a book signing and asked him to write the number 42 in the book he was signing. When my friend got his book back, 42 was written as 101010.