Backbone.js的模式是否破坏了CI的MVC
我将 Backbone.js 与 CI 一起使用。 所以就有了MVC前端和后端。
Backbone.js 所需要的只是从服务器返回的 JSON 响应,然后它将负责显示,并将响应分离到不同的模型中。 因此,我在 CI 模型中回应了这一点。所以我的工作流程是:
CI 控制器 -> CI 模型 (echo) -> Backbone.js
这是混合 Backbone.js 和 CI 的方式吗?还是我做错了?
为了实现 REST,我这样做了:
$this->input->server('REQUEST_METHOD');
然后使用 switch 语句将控制器中的函数路由到正确的函数,然后发送到模型,该模型回显 json。
I am using Backbone.js together with CI.
So there is a MVC frontend and backend.
All Backbone.js needs is a JSON response back from the server, then it'll take care of the display, and handle the separation of response into different models.
Therefore, I echoed the resp back in a CI model. So my workflow is:
CI Controller->CI Model (echo)->Backbone.js
Is this how you would mix Backbone.js and CI? Or am i doing it wrong?
To implement REST, I did this:
$this->input->server('REQUEST_METHOD');
and then a switch statement follows to route the to right function in the controller, and then send to the model, which echo back json.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前的 CI 可能并不是纯粹基于主干的 UI 的最佳匹配。如果您将 CI 路由本质上设置为“RESTful”,并且纯粹返回 JSON,那么您可能没问题,但您最好在 CI 实例中或之外建立一个完整的 REST 服务器。
CI as it stands may not be the best match for a purely backbone based UI. If you work up your CI routes to be "RESTful" in nature, and are purely returning JSON, then you are probably OK, but you may be better off standing up a full blown REST sever in leu of or in addition to your CI instance.