Bubble’s option-set alternative in toddle.dev using variables

  • matt_apollodev-1311433036646318181

    Matthieu B.

    4 months ago

    Hey toddlers,

    Coming from bubble, I’m basically wondering how I could use an equivalent of option-sets

    Let me explain. It’s a very simple use case.

    Let’s say I have a list of 3 categories, (Sales question, product info, Bug)

    1)
    I want to display them programmatically, in a list, avoiding me to :
    - misspell a category name
    - Add or remove categories in one place, without having to modify the UI each time.

    2)
    When I click a category, I want the ‘category’ to be “selected, and show the user a different UI, when selected.


    Back to bubble.
    Bubble’s Option-set are stored on the client’s browser, but act a bit like database.

    So in toddle, I guess, I could create my categories in the database, like a classic table
    But I was thinking of using variables to solve my issue.


    Question :
    was that clear ?
    If so, do you have a solution ?
  • matt_apollodev-1311433441740324917

    Matthieu B.

    4 months ago

    Bubble’s option set alternative in toddle.dev using variables
  • Bubble’s option-set alternative in toddle.dev using variables
  • tomthebigtree-1311452968872312885

    Tom Ireland

    4 months ago

    Hey, Matthieu. Option sets in Bubble sound like arrays to me. You can create a variable and then add an array with your category options as you mentioned.

    An array is a data structure and can be used for lots of different things. For example, creating a list of navigation items and much more.

    In the browser, values stored in variables do not persist, so you’d need to leverage local or session storage to have these persist. Under the hood, I think this is very similar to what Bubble does but it abstracts the terminology and logic.

    It’s worth checking out this course for Bubble devs coming to toddle in the toddle Academy:

    https://toddle.dev/academy/a-bubble-developers-guide-to-toddle

    Also check out the toddle YT and Andreas’ video on data structures.

    Does that help?
  • tomthebigtree-1311455633383362571

    Tom Ireland

    4 months ago

    To handle point 2, this will require the use of classes to style an element based on the selected state. For navigation, it depends on whether the UI should load on the same page or a different page. There’s a few ways to skin a cat. It would be good to start with the design and then work toward fleshing out the logic, etc., to handle the interactivity.
  • tomthebigtree-1311456204454629449

    Tom Ireland

    4 months ago

    One principle is to have some data first, so maybe list out your categories, etc., then use the power of toddle like repeat elements and so on to dynamically render your design with less elements in the element tree. You’ll learn that stuff quick.
  • matt_apollodev-1311538780959801356

    Matthieu B.

    4 months ago

    yeah totally get it, thanks a lot.

    here is how I solved it :

    Have one array variable "category-list".
    And one object variable "stelected-category"

    On click of the category div, just change the variable.
    and bind the UI elements to that variable.


    category-list
    [
    {
    "category": "Sales Question",
    "description": "Happy to clarify anything you like"
    },
    {
    "category": "Product Information",
    "description": "Always fortunate to hear from you"
    },
    {
    "category": "Bug",
    "description": "We will do our best to fix them"
    }
    ]
    👍1
  • Tod-1311538782930997299

    Tod

    4 months ago

    Great energy @Matthieu B.! Your continuous contribution to the toddle Community just made you advance to Community Level 2!
  • tomthebigtree-1311551985488760904

    Tom Ireland

    4 months ago

    Nice one, Matthieu! 👌🏻

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.