在我的Ember.js应用程序中的localStorage.clear()或deleteRecord()之后,本地存储数据被复活 [英] After localStorage.clear() or deleteRecord() in my Ember.js app, local storage data are resurrected

查看:447
本文介绍了在我的Ember.js应用程序中的localStorage.clear()或deleteRecord()之后,本地存储数据被复活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 localStorage.clear() deleteRecord() jsbin示例)在我的ember应用程序中调用。

I'm observing a data resurrection after localStorage.clear() or deleteRecord() (jsbin example) is called in my ember app.

按照以下步骤复制问题:

Follow these steps to replicate the problem:


  1. 打开chrome web dev - >资源 - >本地存储 - >< a href =http://jsbin.com =nofollow> http://jsbin.com

  2. 在此页面上添加一些组织,并观察它们被添加到本地存储

  3. 点击清除本地存储(情况1)或删除组织数据(情况2),并观察本地存储被清除。不刷新页面。 (数据仍然保留在页面上,但由于我们还没刷新页面,所以没关系。)

  4. 添加一个组织,观察所有已删除的组织是否复活(情况1)或LS没有删除(案例2)

  5. 所以当您刷新页面时,所有已删除的数据将被重新排列。

  1. Open up chrome web dev --> Resources --> Local Storage --> "http://jsbin.com"
  2. Add some orgs on this page and observe that they are added to local storage
  3. Click on "Clear local storage" (case 1) or "Delete Org data" (case 2) and observe that the local storage is cleared. Do not refresh the page. (Data still remain on the page but that's okay because we haven't refreshed the page.)
  4. Add one more org and observe that all the deleted orgs are resurrected (case 1) or LS is not deleted (case 2)
  5. So when you refresh the page, ALL THE DELETED DATA ARE RESURRECTED.

问题:


  1. 为什么这个数据复活发生?

  2. 如果在清除(手动或调用 location.reload )之后,如何使localStorage.clear() code>)?

  1. Why does this data resurrection happen?
  2. How can I make localStorage.clear() work even without a refresh after clear (either manually or calling location.reload)?

稍后编辑以包含deleteRecord()

推荐答案

在9月版本的Ember Data / Local Storage中修复了问题。 使用jsbin在这个SO答案中看到它

Problem fixed in September's version of Ember Data/Local Storage. See it in action in this SO Answer with a jsbin.

在IRC上与人们进行了一些讨论之后,LSAdapter或Ember Data中存在一个导致数据流失的错误。

After some discussions with folks on IRC, there is currently a bug in LSAdapter or in Ember Data that causes the data to linger around.

问题出在由于Ember Data即将发生变化,因此暂停截止2013年8月。

The problem is on pause as of August 2013 due to imminent changes in Ember Data.

此问题的解决方法是清除本地存储以及余烬数据。 看到它在这个jsbin中工作

The work-around for this problem is to both clear the Local Storage as well as the ember data. See it working in this jsbin.

或者,您可以在清除本地存储之后立即调用 location.reload()来显示新数据。

Alternatively, you can immediately call location.reload() after clearing local storage to show the fresh data.

这篇关于在我的Ember.js应用程序中的localStorage.clear()或deleteRecord()之后,本地存储数据被复活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆