使用ribs.js(多个视图,模型,集合)一次加载整个模块 [英] Loading entire modules at once using backbone.js (multiple views, models, collections)

查看:80
本文介绍了使用ribs.js(多个视图,模型,集合)一次加载整个模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在考虑使用骨干.js重建非常陈旧的内部CMS的想法,这样我就可以构建比网站更多的应用程序. 到目前为止,我对主干感到满意,并添加了require.js来将应用程序分为模块,但是有一件小事困扰着我.

I've been toying with the idea of rebuilding a very antiquated in-house CMS using backbone.js so that I build more of an app than a website. So far I'm comfortable with backbone and I've added in require.js to break the application into modules but there's one small thing that's bothering me.

我对主干的印象是,可以在单个初始有效负载中将应用程序交付给用户,但是由于添加了require.js,因此所有模型,集合,视图和模板都是临时获取的.

My impression of backbone is that it would be possible to deliver the application to the user in a single initial payload but since adding require.js all models, collections, views, and templates are fetched individually on an ad-hoc basis.

是否可以将我的应用程序分解为模块化有效载荷?例如,如果用户进入CMS的新闻部分,那么他们会收到该模块所需的所有视图,模型等信息吗?我能想到的唯一解决方案是将模块的所有部分包装在一个define函数调用中,但这似乎打破了将应用程序的各个部分分离开的范式.

Is it possible to break my application into modular payloads? For instance if the user enters the news section of the CMS they are delivered all the views, models etc. required for that module? The only solution I can think of is wrapping all the pieces of a module in a single define function call but this seems to break the paradigm of uncoupling the pieces of the application as a whole.

有什么建议吗?

推荐答案

简短答案:

尝试使用requirejs模块

try using requirejs modules

长答案:

检查一下

https://github.com/ravihamsa/base-example/ 

我使用requirejs制作了样板,我将每个模块称为应用程序,每个模块可以编译一个JS文件,并与

I made an boiler-plate using requirejs, I call every module as an app, you can compile one JS file per module, and coupled with coupled with

https://github.com/ravihamsa/baseapp/ 

您可以按需加载每个模块.但是您必须遵循我遵循的url模式.像

you can load each module on demand. But you got to follow the url pattern I do follow. like

http://yourapp.com/#appId/pageId/param1=value1;param2=value2

整个应用程序架构仍在进行中,但您获得了足够的见识

Whole app architecture is work in progress but you get enough insights

这篇关于使用ribs.js(多个视图,模型,集合)一次加载整个模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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