Grouped sidebar button failed to fire click event

https://snippet.dhtmlx.com/vfztwmyr

Pls see the link.
Since there’s no select event for sidebar, I use click event.
One of the grouped buttons should be selected, I hope this event be hooked. So I tried to fire a click event on load, but failed. If the navitems are ungrouped, this can work. How can it be fixed.
Thx

Hello @jyginger,

It looks like an issue on our end, as suite looks for groups property, when the actual property name is group.

I sent it to the dev team, and they will try to fix it in future updates.

There is no good workaround for this case. If the requirement is to run some logic on initial load&selection you may create some custom function, and use the select method inside it, like follows:

function customInitialSelection(){
    sidebar.select("dashboard");
    console.log("some custom logic ")
}

customInitialSelection();

Here is a demo:
https://snippet.dhtmlx.com/x8rc5zhx

Kind regards,

Hi Siarhei,
Thanks for ur quick reply and workaround.

Hope the fix come out soon.

Hello @jyginger,

Update on the fire of the click event - the issue was connected with async operations of the Sidebar, and considered as not an issue.

In the provided demo - it can be avoided with small timeout, like follows:

setTimeout(() => {

    sidebar.select("dashboard");

    sidebar.events.fire("click", ["dashboard"]);

}, 100);
setTimeout(() => {

    sidebar.select("dashboard");

    sidebar.events.fire("click", ["dashboard"]);

}, 100);

Here is a demo:
https://snippet.dhtmlx.com/l77oyiyu

But the suggested workaround, with calling api from some user function is still a preferable solution for your case.

Kind regards,

Thanks for ur reply.
It works perfectly as I follow ur instructions.

1 Like