How to disable and disconnect button link from lightbox pop up when on condition

Hello! I’m very new to coding and have been trying to work around my wixsite with simple codes.
I want to make the button element (#button27) gray out and disable the link when the database’s field text consists of the word “open”
it should look like this:

and vice versa, enable link when text consists of the word “closed”.

These words will specifically located in:

  • content manager named “Status” (#dataset5)
  • in the field name “Commission Status” with field key commissionStatus.
  • has field type text. which will consist of the word “closed” and “open”

with a note: the database text will change from close to open or vice versa from time to time.

  • the text element showing “open” and “close” word have this ID #text54 connecting to the “Status” collection database (#dataset5).

I’ve tried mix-matching some codes to my knowledge after browsing for the solution. Like this based on

$w.onReady( () => {  
    $w("#dataset5").onReady( () => {    
        $w('#text54').value = $w("#dataset5").getCurrentItem().commissionStatus;     
        if ($w('#text54').value === 'Yes') { 
        } else { 

But it doesn’t work… I know the code is probably wrong somewhere and unfinished… but I have no idea how to code it…
Also tried this code but not working too (from )

$w.onReady( () => { 
    if ($w("#text54").text.includes("Open")) $w("#button27").disable();

Please help me… thank you in advance!

Hello. $w(“#myDataset”).onReady isn’t pointing to your dataset, so your code is never executing. Change it to $w(“#dataset5”).onReady. So the whole code should look like:
$w.onReady( () => {
$w(“#dataset5”).onReady( () => {
$w(’ #text5 4 ‘).value = $w(“#dataset5”).getCurrentItem().commissionStatus;
if ($w(’ #text5 4 ‘).value === ‘Yes’) {
$w(’ #button27 ‘).enable();
} else {
$w(’ #button27 ').disable();

EDIT: Still need help
but I’ve noticed out that the code work on unlinked buttons. The thing I have to do now is to put code that unlinks the button from the lightbox window so that the button can gray out and be unclickable. It’s currently looking like this:

What needed: code to unlink the lightbox window on the button.

How do I unlink the button from the lightbox window?

Can you help me again with this? Thanks again!

I’m trying to understand what exactly is your setup. What do you mean by “unlink the Lightbox window on the button”? Do you just want to disable the button so the site visitor can’t open the Lightbox? As shown above in the different code snippets, all you need to do is to disable the button like this:


What else are you trying to do?

Hi! I meant to make the button gray out (which is disabled, unclickable, so the lightbox should be disconnected from the button at a condition that has the word “Open”). I did try the code you provided, but it doesn’t work which the button doesn’t gray out and if I click the button, a lightbox still pops up.

To add up, the $w ( ‘#button27’ ). disable (); code works if only: when I remove the button’s link from the Wix editor which means the button never linked to anything and I don’t want to do that as I still need the button to function in certain conditions I mentioned above…

I hope my explanation makes sense to you…

Although after a long thought I decided to come up with another solution that is to hide the button completely :sweat_smile: and take another way to deliver my needs… I guess that makes this thread already solved then…
Unless anyone is kind enough to leave some explanation on how to disconnect the button’s link programmatically.

Thank you for the response anyway!

1 Like

@kofuustuff Glad you got it figured out, but disable() should work.