如何使用 Backbone.js 构建文件夹和文件项的模型
我正在开展一个项目,或多或少地使用网络技术复制 OS X Finder。
决定使用 Backbone.js 并阅读这个有用的教程 在构建我的代码时,我遇到了一些概念性问题。
如何使用 Backbone 最好地建模文件夹和文件(其中文件可以是多种类型)之间的关系?
我的基本模型应该是带有文件夹扩展名的文件吗?
或者让它们成为单独的模型会更好吗?
鉴于我需要创建可以包含文件夹和文件的“共享”、“最近”和“收藏”视图,这种关系如何工作?
编辑就像经常发生的那样,我继续谷歌搜索并发现这个插件 到 Backbone 这似乎正是我所需要的。如果有人有任何进一步的建议,我很乐意听到。
I'm working on a project to more or less replicate a OS X Finder using web technologies.
Having decided to use Backbone.js and read this useful tutorial on structuring my code I have come to a bit of a conceptual problem.
How do I best model the relationship between Folders and Files (where files can be multiple types) using Backbone?
Should my basic Model be a File with Folders an extension of it?
Or would it be better to make them separate Models.
Given I need to make 'shared', 'recent' and 'favourite' views that can contain both Folders and Files how does this relationship work?
EDIT Well as so often happens I continued Googling and found this add-on to Backbone which seems to be exactly what I need. If anyone has any further advice I'd be happy to hear it though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会让它们成为单独的模型,因为它们确实是不同的概念。或者,您可以只拥有文件,每个文件都包含一个路径属性,其中包含根目录的完整路径。不过,您可能最终需要进行大量解析。
I would make them separate models since they really are different concepts. Alternatively you could just have File, each containing a path property with the full path from the root. you might end up having to do a lot of parsing though.