question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refresh another component after an action

See original GitHub issue

Hi there, I would refresh a navbar component (Cart icon with total of elements inside it) when a product was added to the cart.

Anyone can help me figure out how to do it?

<!-- Component 1: Add to cart button -->
<form sprig s-method="post" s-action="commerce/cart/update-cart">
    <input type="hidden" name="purchasableId" value="{{ variantId }}">
    <button type="submit">Add to cart</button>
</form>

<!-- Component 2: Icon in the navbar with number of items in the cart -->
<div id="cart-icon">
    {{ cart.lineItems|length }}
</div>

Schermata 2020-08-17 alle 15 46 14

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
bencrokercommented, Aug 29, 2020

Added a “Refreshing Components” recipe at https://putyourlightson.com/sprig-cookbook#refreshing-components.

0reactions
bencrokercommented, Sep 14, 2020

Great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Refresh a Component in Angular - Stack Overflow
I'm struggling with refresh action in a component. I would like to refresh the router's components on button click. I have refresh button...
Read more >
Refresh Angular Component Without Reloading The Same ...
If you are working with Angular and need to refresh a component without navigation on another component without using window.location.reload() or ...
Read more >
Angular: Reload/Refresh a Component or Entire Application ...
An Angular tutorial on how to reload/refresh a single component or the entire application and reuse the logic across multiple components.
Read more >
apex - How to refresh one component from another ...
Sometimes, you know that the cache is stale. If the cache is stale, the component needs fresh data. To query the server for...
Read more >
Angular - How to refresh the component - YouTube
Angular tutorial. This is example how to refresh angular component using router0:00 Use case0:57 Solution3:37 Trying to learn pianoAngular ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found