Unable to show/hide entities with "Sandcastle.addToolbarButton"

I try to put a button to show/hide some entites.
I'have tried with ToolbatButton and/or Checkboxes, but theses fonctionalities never works. I started with the hello world exemple and I putted JSON dataSources (and i can see them), but the button doesn't appear. I used this (from your exemple "Show or Hide Entities"):

Sandcastle.addToolbarButton('toits', function(){
    dataSource.show = !dataSource.show;
});

Firstly Firebug told me he was unable to find Sandcastle, so I putted this in the head of my html page:
<script type="text/javascript" src="Sandcastle/Sandcastle-header.js"></script>

Now firebug tell me:
TypeError: document.getElementById(...) is null
  document.getElementById(toolbarID || 'toolbar').appendChild(button);

Any idea?
Thanks in advance
Nicolas

Hello Nicolas,

Sandcastle is a great tool for testing code and learning features, but you should not include it in your own application.

Instead of using Sandcastle.addToolbarButton you should add a to your HTML and add a click handler to it.

Best,

-Hannah

1 Like