question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't require blockly directly

See original GitHub issue

I want to use budo to develop a blockly application. Therefore I need to require blockly directly. In order to export Blockly and goog as global variables I’ve modified the “blockly_compressed.js” file and added these two lines at the end of the file

window.Blockly = Blockly;
window.goog = goog;

My index.js looks like this

require('./blockly_compressed');
require('./blocks_compressed');
require('./javascript_compressed');
require('./msg/js/en');

document.body.innerHTML = `
<xml id="toolbox" style="display: none">
  <block type="controls_if"></block>
  <block type="controls_repeat_ext"></block>
  <block type="logic_compare"></block>
  <block type="math_number"></block>
  <block type="math_arithmetic"></block>
  <block type="text"></block>
  <block type="text_print"></block>
</xml>
`;


var workspace = Blockly.inject('blocklyDiv',
    {toolbox: document.getElementById('toolbox')});

When I run the application with budo index.js I get the following exception:

blockly_compressed.js:1437 
Uncaught Error: container is not in current document.
Blockly.inject	                   @	blockly_compressed.js:1437
5../blockly_compressed    @	test.js [sm]:33
s                                         @	_prelude.js:1
e	                                   @	_prelude.js:1
(anonymous function)	   @	_prelude.js:1

Can anyone give my a hint what I’m doing wrong? Thanks 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
rachel-fenichelcommented, Apr 17, 2017

Hi green-coder,

We’re aware that this is a pain point for some of our developers, and it’s definitely on our to-do list.

1reaction
RoboErikGcommented, Apr 13, 2017

Hi green-coder,

What Rachel means is you should try e-mailing the list. There are a lot more people with experience in different setups on the mailing list who can help debug specific problems. We try to keep the issue tracker just for feature requests and bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't require blockly directly - Google Groups
I want to use budo to develop a blockly application. Therefore I need to require blockly directly. In order to export Blockly and...
Read more >
Get Started | Blockly - Google Developers
Blockly is 100% client side, requiring no support from the server. There are no 3rd party dependencies. Everything is open source. Get the...
Read more >
Can't call any Blockly methods in index.html even though it ...
Blockly object, so there is no such window. workspace variable that would be created unless one of your other scripts (not shown) created...
Read more >
Getting started with Blockly
Blockly is a library for building block programming apps. ... Blockly includes everything you need for defining and rendering blocks in a drag-n-drop...
Read more >
Anybody Can Code With Blockly - Strumenta
Notice that it is not immediately obvious how the blocks will look and work just by looking at the toolbox configuration. You do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found