I know this is not F7 related but it is widely used in F7.
everything went well setting and getting value from localstorage
but i noticed. the localstorage value is not
really updating unless i refresh the page.
Well, i can’t show the whole codes as they are already complex and hard to explain.
but ill show how i do it…
//let’s this is the html where the localstorage value should appear
[div id=“sample-id”][/div] (i realized html tags dont appear here)
// app.js
let eid= localStorage.getItem(“eid”); // get the item
$(’#sample-id’).html(eid); // wont appear for the first load
console.log(eid) // but the eid value appears on console.
even i put the codes inside the
function samplefunc(){…
-$(’#tabbar-main .tab-link-play’).on(‘click’, function() { …
btw, i use sessionStorage instead of localStorage because i just need the browser or app to hold temporary data during user’s browsing… like event_id ← to know which event they are viewing.
localStorage is often used in login feature.
This is how we do it in f7 may be it will helpful for you
//let’s this is the html where the localstorage value should appear
// change here
${loaded && [div id=“sample-id”][/div] }(i realized html tags dont appear here)
// app.js
// change here
let loaded = false;
let eid= localStorage.getItem(“eid”); // get the item
// change here
if (eid){
loaded = true;
$update();
}
$(’#sample-id’).html(eid); // wont appear for the first load
console.log(eid) // but the eid value appears on console.
even i put the codes inside the
function samplefunc(){…
-$(’#tabbar-main .tab-link-play’).on(‘click’, function() { …
Is the value that you’ve saved in localStorage a plain text value, or an HTML-encoded string? You could just another jQuery modifier other than ‘HTML’ to render it, such as ‘text’. You can also use Framework7’s Dom7 to manipulate the DOM this way.
I actually got the logic…
but this ${loaded && ← thing is giving me error.
i think this is placed with
all my codes are in app.js
not inside the pages/whateverpage.html where there is export…
im still using the old-school js procedural method
but thank you for the effort… ill keep this as future reference