Page 1 of 2

Hide apex-chart with button

Posted: Mon Apr 01, 2024 10:42 am
by kknm
There are 3 diagrams on the page. Two of them are in the same position. I need to switch their visibility using a button. Only one of them should be visible at a time.

Code: Select all

function visi(event) {
    if (nuIsHidden('dia_sh_m')==false) {
        nuHide('dia_sh_m');
        nuShow('dia_sh_m1');
    }else {
        nuHide('dia_sh_m1');
        nuShow('dia_sh_m');
    }
}
With this approach, everything works as it should, but in the console I see errors -

Code: Select all

nucommon.js?ts=20240401105906:1311 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at nuShow (nucommon.js?ts=20240401105906:1311:73)
    at visi (<anonymous>:23:9)
    at HTMLButtonElement.onclick (index.php:1:37)

Re: Hide apex-chart with button

Posted: Mon Apr 01, 2024 10:55 am
by kev1n
What version of nuBuilder are you using? (Options menu -> Version Info)

Re: Hide apex-chart with button

Posted: Mon Apr 01, 2024 12:05 pm
by kknm
V.4.5-2024.03.05.02

Re: Hide apex-chart with button

Posted: Mon Apr 01, 2024 12:32 pm
by kev1n
It looks like there is somehow no tab selected/it does not exist. Have you removed any tabs from your form or changed anything else?

This code fails:

Code: Select all

$('.nuTabSelected')[0].id.substr(5);

Re: Hide apex-chart with button

Posted: Mon Apr 01, 2024 12:58 pm
by kknm
'dia_sh_m' and 'dia_sh_m1'- these are not tabs but HTML objects (diagrams) on one tab.

Re: Hide apex-chart with button

Posted: Mon Apr 01, 2024 1:50 pm
by kev1n
Yes but the error is caused because there seem to be no (active) tabs.

Re: Hide apex-chart with button

Posted: Tue Apr 02, 2024 7:59 am
by kknm
What do you mean no active tabs?
This is a LAUNCH form on which 3 diagrams (apex-chart) are placed, described in an HTML object. 2 of them overlap each other. Their visibility is toggled with a button and works correctly, but I have doubts - am I correctly referring to HTML objects simply by name?
dia.png

Re: Hide apex-chart with button

Posted: Tue Apr 02, 2024 8:05 am
by kev1n
nuShow() and nuHide() call a function to update the active tab. If for some reason there is none, you'll get the above error.
tabs.png

Re: Hide apex-chart with button

Posted: Tue Apr 02, 2024 8:25 am
by kknm
I have an active tab, judging by the form properties, and I have permissions for the user.
dia1.png
dia_permiss.png

Re: Hide apex-chart with button

Posted: Tue Apr 02, 2024 8:29 am
by kev1n
And that tab is visible on your form?