Is Backbone.js a web framework for client-side? or both?
I have known that backbonejs is using for client-side so as some examples on backbone.js those examples are loading backbone.js using . But I can search and download backbone module (for nodejs) from npm and there are some approaches to use backbonejs on the server-side.
How is it possible?
And is using backbonejs on the server-side intended by founder of backbonejs ?
Related
I am trying to integrate Angular with Django. I have 2 approaches which one is the best way:
Build a separate angular app and serve it's static files to django to render. In this way the routing and rendering everything will be handled by Angular.
Or to build templates in django using Angular directly and use MVT architecture of Django only.
Which is the correct way from architecture point of view? If not these two please suggest any good approach.
I'm not using AngularJS (actually I'm using VueJS but it's kinda the same) but here is what is usually done :
You do your models as usual, using Django. It defines your database structure.
You build an API that exposes your datas. For that you can use DRF (Django Rest Framework) for a REST API or graphene-django to build a GraphQL API)
You code components to build pages. And you retrieve your datas to display from the API.
For my project, I personnally use :
Django
graphene-django for a GraphQL API
Apollo Client to fetch data from the GraphQL API
VueJS for the frontend components
There are lots of tutorials on how to combine all of these so I guess there are some for AngularJS too.
You should be able to do something similar with AngularJS.
Finally, it is more like the first approach that you described. You'll have some build step that will create a bundle of files with a index.html or similar. The thing to do is to tell Django : "Hey, for any URL, point to that file".
Note that the thing I'm describing is for building a SPA (Single Page Application).
I wonder if anyone has ever loaded angular2 components into an existing requirejs backbone project, as a way to slowly migrate a backbone require.js project into Angular2 ?
regards
Sean
I am working on a Laravel project with Backbone.js and I am stuck with router issues. I want my Laravel project to be a Single Page App (SPA), so at Backbone.js side, I am using hash fragments for links, but Laravel's Route is not recognise my Backbone's hash signs.
I understand that there is also pushState alternative for this purpose.
How can I use routers for a Single Page App, for both server and client side?
When you use Backbone.js you communicate the server through its API. In your Laravel project just create a RESTful API, so you can GET and POST data from/for it. In Laravel you use only models representing the resource and controllers handling the API requests. The routes for these API controllers don't have to care about hashtags, they are just regular routes. In the Backbone client all you have to do is to set the API URLs in your models to your resources in your Laravel back end, then you can fetch and use them.
We are about to write a compojure app with AngularJS as the front-end framework.
Should we be writing the views and partials in hiccup ?
These are going to be static pages and templates and I don't see any major benefit in doing so.
Should we have the API in CLojure only and keep Angular templates in regular HTML?
If using angular you shouldn't be using hiccup on the server to render views and partials.
With angular you can treat your clojure app as an api server, rendering with hiccup would only waste resources, just serve those resources static.
There is a complete application using angular and clojure here which you can use as guide, github repo here
How can I use a jQuery library (Masonry) in a backbone.js application? Should I add it to my view render method? Can you provide an example?
jQuery plugins work great in Backbone apps, since Backbone uses jQuery under the hood of the Backbone.View
I've written a few articles on using jQuery plugins with Backbone, and while I don't show how to use Masonry specifically, the principles that I go through should get you down the path to making it work with your app.
http://lostechies.com/derickbailey/2012/02/20/using-jquery-plugins-and-ui-controls-with-backbone/
and
http://www.kendoui.com/blogs/teamblog/posts/12-11-26/backbone_and_kendo_ui_a_beautiful_combination.aspx