Ready method is ignored

When a cell is created as hidden, the ready function is never called in the view.

For example:

import { Toolbar } from "./Toolbar";
import { View } from "dhx-optimus";

export class TopLayout extends View {
    init() {
        return this.layout = new dhx.Layout(null, {
	        rows: [
			    { id: "toolbar", hidden: true, height: 56, init: cell => this.show(cell, Toolbar)},
		    ]
	})
}

ready() {
	console.log("TopLayout ready")
	setTimeout(()=> {
		this.layout.getCell("toolbar").show()
	}, 1000)
}

Now in Toolbar.js we have:

import {View} from "dhx-optimus";

export class Toolbar extends View {
  init() {
	return new dhx.Toolbar(null, {
		data: [
			{type: "navItem", value: "My NavItem"}
		]
	});
}

ready() {
	console.log("Toolbar Ready")
}
 }

We can see the content of Toolbar view but console.log("Toolbar Ready") was never called.

Hello cstff.

I apologize for such a long delay with the reply.
Unfortunately it is not recommended to initialize the component to a hidden layout cell, as it is not presented in the DOM. THe better solution will be to initialize the layout cell with the height: "content" (as the cell is empty it will have the null height) and add the component to that cell when it is needed.

1 Like