Help forum

How do you make a button change the screen? (not going to an external url)

  • PandaBearMe

    1 year ago

    I'm curious how I can use buttons to change the div it's showing in my application, but I only see tutorials for how to make buttons go to a link.
  • Lucas G

    1 year ago

    A button could change a variable which controls the show/hide conditions to display the components
  • PandaBearMe

    1 year ago

    would I go under events > when clicked > to control the show/hide conditions?
  • Lucas G

    1 year ago

    When you right click an item in the element tree, you'll see this context menu (some of these are also available in the right side panel under Attributes)
    1347310207600169021-image.png
  • Lucas G

    1 year ago

    Then under the events -> click for the button you can configure whatever you're using to show/hide the elements
  • PandaBearMe

    1 year ago

    so I can make a show/hide formula under the attributes?
  • PandaBearMe

    1 year ago

    I see hide and show under the attributes section, but I'm not sure how I'm supposed to link it to a page or activate it
  • Lucas G

    1 year ago

    It's the same option just accessible from different places
  • If you read through the doc or go through the videos in the toddle YT channel you'll see a lot of examples
  • Basically the condition needs to return true/false
  • If true the element will show
  • Lucas G

    1 year ago

    So it can be as basic as variable equals "value" or a more complex calculation. The only thing is it needs to return true/false
  • PandaBearMe

    1 year ago

    if I wanted each button to show a different page on my application would I need different divs for it to show or hide depending on which I click?
  • and then I just connect them with the true/false show condition?
  • Lucas G

    1 year ago

    Sounds like you are doing an SPA (single-page app) in which case, yes, that's an optino
  • You can also use page path parameters to control what shows
  • Something very important that you should get used to early is the use of components
  • It sounds like you might be just trying to build everything out in one page
  • You'll end up with a large element tree and a laggy editor trying to render it all at once
  • PandaBearMe

    1 year ago

    Ohh yeah sorry I am trying to do a one page app thats right
  • Tod

    1 year ago

    Great energy @PandaBearMe! Your continuous contribution to the toddle Community just made you advance to Community Level 2!
  • Lucas G

    1 year ago

    Components have a lot of benefits, take some time to get to know them 👍
  • PandaBearMe

    1 year ago

    I've messed with components a little bit but definitely need more familiarity
  • are components key in scaling a project then?
  • Lucas G

    1 year ago

    Yes
  • Check out this channel too for resource outside of the official toddle channel
  • Though I also definitely recommend you check out the main channel if you haven't already
  • PandaBearMe

    1 year ago

    I guess looking into single page applications it doesnt necessarily have to be a single page but just not going out to an external link
  • Lucas G

    1 year ago

    But yes, components are definitely key and a core concept in toddle (similar to most existing frameworks e.g., React, Vue, Svelte, etc)
  • If the page doesn't reload, then it's an SPA
  • PandaBearMe

    1 year ago

    maybe I'm using external wrong but I mean like a link to an existing page on the internet
  • Lucas G

    1 year ago

    That would reload the page, making it an MPA
  • PandaBearMe

    1 year ago

    I just wanted a list of buttons that went to different pages on my application
  • Lucas G

    1 year ago

    multi page
  • PandaBearMe

    1 year ago

    yeah I believe it would be multi page
  • Lucas G

    1 year ago

    Both approaches can work, it is preference and dependent on the type of app
  • PandaBearMe

    1 year ago

    yeah I see
  • unfortunately I don't know how to do either
  • which would be the best for learning?
  • Lucas G

    1 year ago

    The difference is basically are you going to a new page or are you doing everything in one page and showing things based on conditions
  • SPA can be more complex so MPA might be easier
  • PandaBearMe

    1 year ago

    yeah I think I just want something easier to get started
  • I've been watching some videos in that channel you linked actually
  • just haven't quite found something that addresses what I'm trying yet
  • Lucas G

    1 year ago

    That guy likes SPAs
  • His demo build is an SPA I believe
  • And he uses page paths to control show conditions
  • It's a long video but it's in there somewhere
  • PandaBearMe

    1 year ago

    I think I found it from a different thread asking about this
  • I'll have to look at it later unfortunately not enough time 4 hours long 😮