通过删除ID的骨干模式? [英] Remove a backbone model by id?

查看:81
本文介绍了通过删除ID的骨干模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以通过删除ID的模式?文档说,你需要在模型本身传递给删除它。

Can you remove a model by id? The documentation says you need to pass in the model itself to remove it.

所以,我需要首先提取模型,然后将其删除?通过ID我不能只是删除它?

So I need to fetch the model first and then remove it? I can't just remove it by id?

推荐答案

你的意思是从集合中删除模型?综观文档,它似乎像你需要在一个真正的模型通过,但源$ C ​​$ C表明,你可以通过在任一型号 ID 或模型 CID ,以及,上述所有应该工作(以及上述所有的阵列)。

Do you mean remove the model from a collection? Looking at the docs, it does seem like you need to pass in a real model, but the source code suggests that you can just pass in either the model id or the model cid as well, and all of the above should work (as well as arrays of all of the above).

因此​​,所有的以下应该是等价的:

So all of the following should be equivalent:

collection.remove(myModel);
collection.remove(myModel.id);
collection.remove(myModel.cid);
collection.remove([myModel]);

我没有测试过这一点,但是。

I haven't tested this, however.

这篇关于通过删除ID的骨干模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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