PricingBlog

Data lost in variable

  • patrickmast-1254360904284504085

    Patrick Mast

    1 year ago

    I have a test project with two tabs. Each tab is a component featuring two input fields for Name and Address, along with a button. When the user clicks the button, a random name and address are populated into the input fields. Works great!

    The problem is, when I switch between tabs, the values of the variables in the previous tab reset to their default values. They do not retain their values. Is it because these variables are set in the component?

    Here is the test project: https://start-test_tabs_data.toddle.site
  • lucasg-1254429936224043089

    Lucas G

    1 year ago

    Whenever a component is shown via show/hide conditions, it is reloaded each time it is shown.
  • Show/hide essentially takes it out of the DOM on hide and fetches it back on show
  • So all the variables inside the component are reset as it is loaded back
  • lucasg-1254430737617260604

    Lucas G

    1 year ago

    You can use attributes to 'pre-fill' the inputs or use another method for displaying the different tabs
  • patrickmast-1254753446901317683

    Patrick Mast

    1 year ago

    Thanks @Lucas G! Testing more here.