Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Hide apex-chart with button

Questions related to customising nuBuilder Forte with JavaScript or PHP.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Hide apex-chart with button

Unread post 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)
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Hide apex-chart with button

Unread post by kev1n »

What version of nuBuilder are you using? (Options menu -> Version Info)
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Hide apex-chart with button

Unread post by kknm »

V.4.5-2024.03.05.02
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Hide apex-chart with button

Unread post 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);
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Hide apex-chart with button

Unread post by kknm »

'dia_sh_m' and 'dia_sh_m1'- these are not tabs but HTML objects (diagrams) on one tab.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Hide apex-chart with button

Unread post by kev1n »

Yes but the error is caused because there seem to be no (active) tabs.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Hide apex-chart with button

Unread post 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
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Hide apex-chart with button

Unread post 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
You do not have the required permissions to view the files attached to this post.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Hide apex-chart with button

Unread post by kknm »

I have an active tab, judging by the form properties, and I have permissions for the user.
dia1.png
dia_permiss.png
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Hide apex-chart with button

Unread post by kev1n »

And that tab is visible on your form?
Post Reply