Velo Code to Show or Hide Buttons Based on CMS Presence of Link

Question:
I am using the following code to show or hide buttons for links based on presence of links in CMS data and it is working 100%. However, instead of hiding the buttons if no URL, I would rather show them as dim so the format of page looks more consistent. Any thoughts on how to do this?

Product:
Editor X

What are you trying to achieve:
Dim buttons w/o links in CMS

What have you already tried:
Nothing

Additional information:
None

1 Like

β†’ button.enable()
β†’ button.disable()

β†’ button.enabled
β†’ button.disabled

1 Like

In the code editor, Velo is not recognizing .button

1 Like

SET:
$item(β€˜#yourButtonIDhere).enable();
$item(’#yourButtonIDhere).disable() ;

GET:
console.log($item('#yourButtonIDhere).enabled);

And the last one was b u l l s… not existent …
β†’ button.disabled

1 Like

I am a bit new to Velo so I apologize if I am being slow. Velo is also not recognizing .enable() and .disable()

1 Like

Why β†’ $w ??? β€”> your button is outside of REPEATER ?
Or did you want β†’ $item β†’ because your button is INSIDE of REPEATER ?

About enable() and disable()…

1 Like

Button is inside repeater was just experimenting since the .enable() and .disable() methods were not recognized in editor. Not sure what to do here.

1 Like

Maybe it depends on the TYPE of BUTTON.
Maybe not every button supports this functionality β†’ i did not test this.

Maybe the CODE-AUTOCOMPLETION is buggy and is showing you wrong information.

Test the button and see if it gets GREYED-OUT.

If not β†’ take another button β†’ ORDINARY-ONE and test again.

Also check the ID of your BUTTON one more time.

Hold your mouse over the red underlined code-section and see what kind of ERROR you get.

DEBUGGING only works with INPUTS and OUTPUTS and… ??? β€”> YES and β†’ CONSOLE-LOGS.

1 Like

Ok and thanks for your patience - just learning Velo. These are images of things like YouTube logos with links to URLs. Also tried Opacity setting which is also not compatible with image elements.

2 Likes

I know, i am watching a lot of posts. :grin:

1 Like