Updating label on switch toggle


Hello !

I’m new to Wappler and a bit lost for now.
Searching through the forum and docs didn’t answer my questions but I might just search with the wrong terminology…

  1. I’m trying to understand the difference between dynamic events and dynamic attributes.
    I couldn’t find anything relevant for the latter in the documentation.
    Did I miss something ?

  2. I have a switch toggle element.
    And I would like to edit the label attached to it when enabled.

I managed to add a “rule” to update an input when the switch is toogled on : https://www.screencast.com/t/fevGqvPD
But I can’t figure out the syntax to make it work on a label, what kind of language is it ?

Plus that would be only half of the job done as I guess I would have to revert the original label value when the switch is toggled off again. And I have no clue on how to do that.
My guess is that I would need to use jquery somewhere…

All suggestions and ressources are welcomed.

Thank you very much for your help ! :slight_smile:



I’ll answer your first point first. It is easier for this tired old bod to take things one by one so as to not get confused.

An attribute is another word for modifier. An example of an attribute is ‘type’ and ‘name’ for an input field as in
<input type="text" name="fname"> or <input type="hidden" name="lname">

An event is a special type of attribute (confusing?). Events need a trigger caused by an action. Examples of events are

  • on load
  • on click
  • on change

An event can be used to change the value of an attribute.


The second point.

Assuming that the toggle switch is based on a checkbox, off will mean that the box is not checked. In this case you can hide one label and show the other label when the checkbox is checked.



Thank you very much Ben ! :slight_smile:

In the meantime, I found a solution for my toggle issue :

With the following code :
if($(this).is(":checked")) {

I’m wondering if it’s ok to put this kind of script on one line or if there are better practices for code readability !

I’m also still confused about what language is used.
It seems that it’s jquery for static events.
For validation rules and dynamic events/attributes, I just copy/paste what I see in the documentation without knowing what language it is. Can you point me in the right direction ?

Any help is appreciated. Thanks ! :slight_smile:


Your approach seems more elegant (less code). Thanks !


Sure your method will work, but it is not necessary to code when using the Wappler way.

The framework that is used is App Connect which is a JavaScript framework similar to those mentioned here https://raygun.com/blog/popular-javascript-frameworks/. The advantage of App Connect within Wappler is that there is no need to code (with minor exceptions).


Please have a look at this tutorial which contains many of the workflows that you will be using with Wappler https://www.youtube.com/playlist?list=PLUjqTJN3byC9kK8YZkmGwjo9nrEipl2yb


Thank you very much Ben !


Don’t worry, you fall in love with Wappler soon enough.


No need to have two labels
You could use this on the label text attribute
Checkbox.checked? “Checked” : “Not”


Just tried it but couldn’t get it to work.
I must be missing something simple.
Is that supposed to be jQuery code ?

Where would that code go ?

My best bet so far was to update my code to something like that :
(see second section)

Thank you very much for your help !


Don’t know Wappler at all but logic says something like the below should work:

We’ll if I knew how to post some html code it might help - where’s the option for doing that?

Found it:

<input id="myCheckBox" type="checkbox" dmx-bind:value="myCheckBox.checked? 'TTC' : 'HT'">
<label for="myCheckBox" dmx-text="myCheckBox.checked? 'TTC' : 'HT'"></label>


Got it to work finally, thanks.
See https://codepen.io/Jeoff75/pen/MLvYzm

I understood that mrbdrm talked about the dmx-text attribute and not regular html attribute.
But this is not obvious to find as the GUI says “Inner Text” so I couldn’t immediatly make the connection :smile:

And this is “App connect” code I think.

I couldn’t locate a proper App Connect extensive documentation.
Do you know where I can find one ?


Just be aware there is no ‘value’ input in your checkbox field (its empty) unless you bind the value to it. This might just be for visual effect but if you’re returning something to a database or need the value HT/TTC for some other aspect of your overall concept you need to bind the value to the checkbox OR grab the current status from the label field.

Check it out by looking in your browers inspection tools.


Makes sense. Thanks for the help ! :slight_smile:

split this topic #16

3 posts were split to a new topic: App Connect in-depth documentation