Persist Content using local storage

Persist Content using local storage

avneet01avneet01 Posts: 2Questions: 1Answers: 0
edited November 2021 in General

How can we change the button text on its click and then persist after a page reload/browser termination in the below dataTable example:

https://datatables.net/examples/ajax/null_data_source.html

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    How can we change the button text on its click

    The button text is just defined by ""defaultContent": "<button>Click!</button>"" - you would just change that, or did you mean something else?

    persist after a page reload/browser termination in the below dataTable example:

    If you want to persist filtering, ordering and pagination, you can use stateSave - see example here,

    Colin

  • avneet01avneet01 Posts: 2Questions: 1Answers: 0
    edited December 2021

    Thanks Colin for your reply. Using stateSave, I am able to save the button state but when I terminate or reload the browser, it goes back to original state. Please share your valuable inputs on how to persist the state of button using Local Storage so that if I click on it its text should change to maybe 'View' and remain as it is. By default here all buttons have same 'id'/'text' so persisting their state is a bit tricky.
    Thanks in advance!

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    Can you post what you have, please, as that will give us something to work with. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.