简体   繁体   中英

Does the pattern of Backbone.js break the MVC of CI

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM