below is the complete HTML source for creating a simple toolbar with google closing.
Gives an error message in Chrome: Uncaught TypeError: Cannot call method 'addChild' of undefinedin the place marked by the comment // ERROR.
Can anyone suggest a tip fixing this? Thank!!!
edit: right, I missed the new one , but another mistake was that I had to use render()instead decorate(), because it decorate()requires that all dom elements are in place (and I don’t have placeholders for certain buttons), but it render()creates new ones.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="/m/google-closure/closure/goog/base.js"></script>
<script type="text/javascript">
goog.require('goog.dom');
goog.require('goog.ui.Toolbar');
goog.require('goog.ui.ToolbarButton');
</script>
<script type="text/javascript">
var load_sketcher = function(){
var tb = goog.ui.Toolbar();
tb.addChild(new goog.ui.ToolbarButton('A'), true);
tb.addChild(new goog.ui.ToolbarButton('B'), true);
tb.decorate(goog.dom.getElement('sk_toolbar'));
};
</script>
</head>
<body onload='load_sketcher();'>
<div id="sketcher">
<div id="sk_toolbar"></div>
<div id="sk_canvas"></div>
</div>
</body>
</html>
source
share