PricingBlog

[SOLVED] Refreshing component attributes

  • prolax-1199202322857873479

    prolax

    2 years ago

    I have a list of products on a page. Each product has an attribute for whether or not it is in my wishlist.

    I set this attribute with the attached formula, checking if the results of my API call contains the ID of the product. If it contains the ID, set to True, if it doesn't set to False.

    This works when I first load the page. However, if I then add or remove a product from my wishlist, the attribute value is not updated until I refresh the page again.

    The wishlist API request is set to auto-fetch, and it is also being called "when" I trigger my component event to add/remove the product from my wishlist.

    Any ideas on whether I'm doing something wrong here, an alternative solution and/or if this is intended behaviour?

    I've just started diving into components/events/attributes so hopefully it's just a self-inflicted bug
    1199202323134677012-image.png
    1199202323445067849-image.png
  • Tod-1199202325428969543

    Tod

    2 years ago

    Great energy @prolax! Your continuous contribution to the toddle Community just made you advance to Community Level 3!
  • prolax-1199203195960963122

    prolax

    2 years ago

    I guess I'm wanting to know how to re-trigger the formula determining an attributes value, without refreshing the page
  • prolax-1199216102803255316

    prolax

    2 years ago

    hmm odd, it now works when adding items to wishlist, but is not updated when I remove an item from the wishlist. Hopefully I'm just missing something, will dig a bit more
  • prolax-1199216904372498453

    prolax

    2 years ago

    [SOLVED] Refreshing component attributes
  • prolax-1199217574798442558

    prolax

    2 years ago

    confirmed: self-inflicted.

    For what it's worth..

    I had forgot to set the change event to trigger on the removal action, only the add action - so the API wasn't getting called on removal 🫠 still unsure why it wasn't working for either add/remove earlier but some AFK time and a refresh sorted that