如何清除骨干localStorage的 [英] How to clear the backbone localstorage

查看:107
本文介绍了如何清除骨干localStorage的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript的人似乎pretty简单,只需localStorage.clear()。

The javascript one seems pretty simple, just localStorage.clear().

有什么类似的骨干localStorage的,如果没有,可以有人点我就如何做正确的方向。

Is there anything similar to that for the backbone localstorage, and if not, can someone point me in the right direction on how to do it.

我在想这样做这样的事情:

I was thinking about doing something like this:

localStorage.each(localStorage.delete(本))

localStorage.each(localStorage.delete(this))

不会指向元素不是吗?

推荐答案

一些方法可以从收集,但无论你选择的方式做到这一点,你必须调用摧毁每一个模型,它将运行同步并摧毁它两个客户端和服务器端(它的localStorage充当)

Few ways you can do this from the Collection, but whichever way you choose, you have to call destroy on each model, which will run sync and destroy it on both the client-side and server-side (which localStorage is acting as).

collection.each(function(model) {
      model.destroy();
    }
)


更新

每评论,并不像这个作品了。由于这是仍标记为答案,包括答案应该低于工作,每 skcin7

Per comments, doesn't look like this works anymore. Since this is still marked as the answer, including answer that should work below, per skcin7.

while ((model=collection.shift())) 
    { model.destroy();
}

这篇关于如何清除骨干localStorage的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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