Forum Stats

  • 3,734,283 Users
  • 2,246,938 Discussions
  • 7,857,218 Comments

Discussions

How to refresh Item card without refreshing the entire region?

Ahsan Anwar
Ahsan Anwar Member Posts: 19 Red Ribbon

Hi,

I am building an e-commerce application using apex 20.2. I have a cards region to display items. I am using a page submit on "Add to Cart" to display basket icon on the item card to show to the user that this item is added to cart.

This seems not to be a good approach because page submit or region refresh change the position of the screen. That means when a user add to cart an item "A" then he'll be on some other position on the screen and will need to scroll to go back to item "A".

What could possibly be the solution to this problem?

Thanks.

Tagged:

Best Answer

  • Sylvain Martel
    Sylvain Martel Member Posts: 674 Bronze Trophy
    Accepted Answer

    Hello Ahsan,

    I have a hard time visualizing the flow of your screen, but in any case you might be interested in the tip from my friend Jorge Rimblas. It might help you bring the cursor back to the original position on the screen.

    Video: 005 – Restore screen position after refresh

    I believe you have to make a few minor modifications to get it to work.

    Function and Global Variable Declaration:

     var savepos = localStorage.getItem(“savepos”);
    

    Save Scroll Position Javascript Code:

     savepos = $(window).scrollTop();
     localStorage.setItem(“savepos”, savepos);
    

    Making these two changes should make it to work fine.

    Hope this helps!

    Ahsan Anwar

Answers

Sign In or Register to comment.