donglu8344812
2013-01-31 08:52
浏览 41
已采纳

Backbone.js和codeIgniter

I'm using the codeigniter Framework to use my servers side logic, and I want to use backbonejs to manage the client side logic.

I read a lot about it and there are many ways to achieve this, I thought using the following design:

  • In CI , keep only one view for each application. This will be a placeholder for the content that will be pushed by BackboneJS. The BackboneJS will be loaded from this page.
  • In BackboneJS, manage all the application client side , and query the CI controllers (that might call CI models if needed) to fetch the dynamic content.

What is the best way to use them both? Does my design breaks the MVC design somehow?

图片转代码服务由CSDN问答提供 功能建议

我正在使用 codeigniter 使用我的服务器端逻辑的框架,我想使用 backbonejs 来管理客户端 逻辑。

我读了很多关于它的内容,有很多方法可以实现这一点,我想使用以下设计:

  • In CI ,每个应用程序只保留一个视图。 这将是 BackboneJS 推送的内容的占位符。 BackboneJS 将从此页面加载。
  • BackboneJS 中,管理所有应用程序客户端,并查询 CI < / strong>控制器(如果需要,可以调用 CI 模型)来获取动态内容。

    最佳使用方法是什么 他们俩? 我的设计是否以某种方式破坏了 MVC 设计?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douping5226 2013-01-31 13:28
    已采纳

    Premise: I use Yii instead of CI but I think they work in a similar way.

    I have a index view in Yii which contains the main HTML structure of my app (menu, sidebar, main content, etc.) and a main controller which manage the REST requests, using Yii's model to retrieve information.

    On the client Backbone take care of all, each route fire a request to the REST-like api and the views are finally rendered by the client with the data returned from the server in JSON format.

    I don't know if this is the better way, but after some struggling I get it to work and I'm quite happy about it.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题