localStorage not clear at 1st click

Hi ,
I’m trying to clear my local storage when I click the link.

page.$el.on('click', '.tab-link', function(e) {
    if (localStorage.logData) {
    localStorage.removeItem('logData');
    console.log('clear filter:' + localStorage.logData);
    localStorage.logData = '';
     }
 });

and reload the same page init .But 1st load the data still there.
when I click 2nd time then it cleared.

You can debug your app in browser console to look for an error.

no error.
If I just put it on page init localStorage.removeItem(‘logData’); It will remove.
but , when I put it when I click it still there.
somehow , It can not remove from the same page.
It must redirect from other page It will gone.

But , If do it in the same page data still there but actually it’s gone.

Still looking for the solution

I just fixed it by clear the localStorage then go to the page I want.

  page.$el.on('click', '.tab-link', function(e) {
    localStorage.removeItem('logData');
    var tabLink = $$(this).data('url');
    app.views.main.router.navigate(tabLink);
  });