Undefined toolbar


I have one main single cell layout with an attached toolbar. For each item in the toolbar I have separate functions that create a page for each toolbar item. Some of these pages just display to a div, others attach a secondary layout, toolbar and grid.

The problem is that when I pick an item from the main toolbar, the page with the secondary layout, and toolbar get created without any problem, but when I pick another item from the main toolbar and then go back to the last one with the secondary toolbar, I get the following error:

TypeError: toolbar is undefined

The function that creates the page with the secondary layout and toolbar looks like this:

jobs = function() {
var toolbar = ufSMlayout.cells(‘a’).attachToolbar();
toolbar.addButton(‘reload’, 0, ‘Reload’, ‘reload.png’, null);

This function works fine the first time, but when I navigate away from this page and back again I get the error described above. I have thought about making the toolbar variable a global, but would prefer not to have to do that.

Any help would be greatly appreciated.



Could you provide us a direct link ot completed demo to reproduce this issue locally?
docs.dhtmlx.com/doku.php?id=othe … leted_demo

Hi Darya,

Thanks for your reply. I have re-created the problem at the following url:


It is a complete example/demo of the problem which I will summarize:

There are two layouts, the second attached to the first. On the first layout there is a main toolbar with two items, foo and bar. When clicked, each item attaches a it’s own toolbar and grid to the second layout. When the second item (bar) is selected the javascript console complains that the toolbar is undefined. If you go back to the first item (foo) it will also complain that the toolbar is undefined, which it did not do on the initial page load.

I you have any questions or I can provide more information, please let me know. Your help is greatly appreciated.



You’ve posted wrong file path, pleace, chek it:

Sorry about that, I renamed the file and forgot to update the html file. I have corrected the error and the javascript file can now be found. Also the undefined toolbar error still occurs.



Have you compile files via libCompiller or it was completed PRO version?


our components allow to attach only one toolbar or menu. you already have attached toolbar, that’s why when you click “Foo” or “Bar” button at top toolbar you have foo_toolbar set to undefined. call detachToolbar() first or just use existing.

Thanks Andrei I appreciate your help. I have solved the problem by giving each item it’s own layout object and attaching the toolbar to it.