I want to be able to set the value of a checkbox when the text “Click Me” is clicked elsewhere in my design.
That checkbox controls the visibility of some other text “Some text”. This works okay in that when I check or uncheck the checkbox, this text appears and disappears.
The problem is…
When the text “Click Me” is clicked, the checkbox is selected but the text “Some text” does not become visible.
It seems that using just select() doesn’t seem to trigger the checked action, but if you also include a setValue() step then it worked for me (doesn’t seem to need a value…but if you’re using a standard 1/0 for true/false you could set it as 1).
So I was able to check the checkbox by clicking the label, but the data is not reloaded. How can I achieve that? Which action is triggered by clicking the actual checkbox and should thus be triggered on clicking the label as well?
I tried Set value for the checkbox, Set value for the form group, submitting and resetting the form, running the server connect call again, all without success. How can I achieve the same result as when clicking on the actual checkbox instead when clicking the label?
It loads a list of products (filtered on category, style, etc) which is shown in a repeat grid.
Whenever the actual checkbox is clicked the server action is re-run and the new filters apply, so that's what I want to trigger as well when clicking the label.
When the checkbox is clicked, the product list is filtered as intended.
I need the product list also to be updated when a category checkbox's label is clicked (and the checkbox thus checked/unchecked).
Also, when the CategoryID is in the categories query parameter list I need the checkbox to be checked and the product list to be filtered on that category list.
Currently I use this to check the checkbox dynamically, but that doesn't check it when the CategoryID is in the 'categories' query parameter:
On your link i don't see any dynamic dmx-bind:for for labels or dmx-bind:id for the checkboxes ...
Also, in the code you pasted above, the checkbox is missing the dynamic id dmx-bind:id
I updated the url I sent previously. CategoryID = 6 is the 'Dining Chair' category, thus that category filter checkbox should be checked so only products in that category are shown. You can see the category of a product by hovering it's card. Thanks again for your help in advance!
PS: Seems to me it has something to do with loading order: For example, when a category link on a product card is clicked, it does seem to work correctly. And in that case it's an internal link and the page doesn't have to be reloaded completely, so that's why the loading order might be the problem I think. Don't know how to solve that issue however, so hope you can help me with that
You are using a checkbox group component, it has a value which is used exactly for your purposes - to check the checkboxes when the values match.
Remove the checked attribute from the checkbox itself and add: