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?

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料