user3203518
user3203518

Reputation: 51

How to correctly use Nodejs and backbonejs together?

I have an application which uses nodejs as server and backbonejs as the frontend framework. As I know, both backbonejs and nodejs handle the url.

I have a question: for example, let say I have page called localhost/project and a page called localhost/details. When I load either of these pages, nodejs server should be called first, and then in the view.jade I have:

script(type="text/javascript", data-main="/js/bootstrap", src="/js/lib/requirejs/require-min.js")

which initiate the control of backbonejs. So, does that mean everytime that I load a NEW page (localhost/details --> localhost/project), I have to reload all the steps for initializing the backbonejs (requireJS work)?

Upvotes: 0

Views: 75

Answers (1)

Ken Wheeler
Ken Wheeler

Reputation: 1958

Unless you have to do it differently, perhaps a better approach would be to use node.js as a REST API. I would use a framework like express. Then, in your Backbone code, hook your model and routes up to call your node API and update the views with the data it receives.

Unless you are doing any kind of processing on the server side, you can skip the node step and run your SPA's right off of Firebase or Parse.

Upvotes: 1

Related Questions