I have a toggle switch that I’m trying to get installed with custom states. The problem I’m experiencing is that the switch will toggle to ‘yes,’ but I can’t get it toggle back to no afterward. It’s just stuck there. Based on the settings I have I can’t see how this is possible. I’ve noticed in trying to fix this problem that if I switch the order of workflows that it can make this not work at all. Can someone please tell me what I’m doing wrong? Would using PNG images somehow disrupt this?
Have you checked it in debugger? I suppose both workflows are triggered (first when switch is no → switches to yes, next wf toggles back to no) and as a result visually nothing changes.
@artemzheg Yes, I checked it in the debugger. But logically, how else could this work? There are only two settings - yes and no. If it’s not yes, then it has to be no. I guess I don’t know how this would cancel itself out?
Condition needs to be on the workflow event not the action.
Also this can be done in one action by setting the state to the “[element]'s [state] is no”. So if it was no already then that returns a yes and sets it to yes and vise versa.
I’m not sure what I’m doing wrong. I have tried all different kinds of variations on the workflow event and the action. Still not producing any different results.
Remove the other event so it’s just one workflow on the button, remove the condition on the “Set state” action (remove a condition on the event if you have one), then instead of putting the hard “no” or “yes” set the state to “[element]'s [state] is no” so every time it’s clicked it sets the opposite.
That is the most strange logic ever (at least to me)… but it worked! It took me a few minutes to wrap my brain around what you typed out. I’m sorry about that. But thank you so much!
What you had was fine as well (and makes sense, if it’s no make it yes) it probably just needed to be tweaked a little bit, but why have two workflows if you don’t have to
@artemzheg I will most certainly check it out! After working with these I think I can use all the help I can get. haha! When my conclusion to a solution is, “That’s strange logic,” it’s probably a good idea to pick up a book or find a way to learn more. Thank you for the suggestion!
Syntactically it’s dumb, but this is how boolean negation in Bubble works. In most languages it’s either an expression like “not (some_bool)” or there’s a boolean inverse/negation operator often expressed by the ! character. E.g., in JavaScript:
!some_bool
(whatever some_bool is, true or false, !some_bool is it’s opposite - false or true)
Since Bubble operators come after an expression (expression :some_operator), we would assume that there might be a not operator:
some_bool :not
But no, we cannot have nice things.
(The issue is that “is yes” is redundant. You’ll note that some_bool can only be yes or no. Asking is some_bool yes is the same thing as just saying some_bool. We naturally (in programming, boolean logic, natural language, and life in general) just want to say, “not this one, but the other one”, not “is this the negative case of this one? If so, I want the other one.”)
@keith First of all, I would like to say you did a very nice job with the video. I watched it all the way through yesterday afternoon. Very easy to follow and fun natured. I was inspired because I thought it was giving me the answer to my developing problem. I created a video showing my problem (don’t just want to show a toggle switch, it has to be able to hold onto the value).
OK, the reason I put the conditionals this way is because at the 27:57 mark of your video you mentioned you don’t have to put yes or no. I did also try yes and no values to which they failed before. It’s still failing to change the image since trying again as you suggested. Any other ideas?