Javascript-controlled page layout using REST for dynamic content

Asked

Viewed 243 times

5

I was thinking of a different standard to develop my application via browser. As it is an ERP, I need a quick interface that does not need to download the HTML from the server at all times to print the layout on the user screen. The solution would be to make all the interface in javascript, pulling the dynamic content via PHP REST with JSON. The server would only be responsible for printing a JSON to return only primitive variables such as text, integers, Boolean and arrays.

Doubts:

1. That’s a Pattern design acceptable and professional or is gambiarra?

2. Is there a javascript framework that saves me work on the client part (javascript) for this purpose?

3. What pros and cons of using this Pattern design?

  • 3

    Yes, it’s acceptable and it’s on the rise. It’s called Singlepage Application or SPA. There are several frameworks like Knockoutjs, Emberjs, Angularjs, Backbonejs that do DOM control and MVW rule maintenance (Model View Whatever)

  • I do not understand what kind of improvement could be taken advantage of, creating all the layout in javascript, I think that for static content, use only html, ensures much more the display of the page, because if the user is with javascript disabled, your entire site, will not be neither viewed.

  • 1

    Yeah, state content would be in HTML. Javascript would only be responsible for making requests on the server to get the JSON information and take control of the DOM like you said. It’s easier to research now knowing that this is called SPA and with your frameworks suggestions. As for javascript disabled, it is a bad thing that I will have to combat, force users to enable. In fact, I don’t even care about it, since it will be a commercial/business application with specific users and all would be trained to use and obviously would not disable javascript.

  • 1

    In this case yes, it is advantage, as it is an ERP, there is no need to worry about SEO, which is a problem when talking about Ajax requests, which there are also techniques to circumvent...

  • 1

    @Gustavopiucco I do not know if you have already started but I recommend a look at the nodejs to do the backend. It has great performance and scalability, and the learning curve is not so great for those who already know Javascript

  • 1

    I haven’t started yet. I am aware of Nodejs, only that as I am thinking in the long term, as Nodejs has apparently come out of the oven now, I don’t know what the future of its development will be, I feel safer developing in PHP, maybe I’m wrong.

  • 1

    Yes, for an ERP it looks good. BUT... there has to be a very serious commitment to the adopted standard. The moment you start delivering HTML inside a JSON, abandon the :D boat

  • 1

    @Gustavopiucco has little time for us Brazilians, but Node has more than 2 years and is being embraced by numerous large companies. As you said yourself, as it is in the long run, a technology that is already emerging today may be a good choice.

  • Or Angularjs, from that little company...

  • 1

    @Gustavopiucco Was something missing in my reply? Can you add a comment that I will try to complement

Show 5 more comments

1 answer

6


MVC or MVP or MVVM

(Model-View-Controller / Model-View-Presenter / Model-View-Viewmodel)
(The choice depends on what suits you best and what you want to do)

This way you split the application rules into layers.
In the Model, you can create all entities and core business rules in one Webservice in any language or platform and, from it, make the data available and interact with your website, without there being a real link between them. Only one contract Model Public Interface for Fronend.

Advantages of layering

Split your application by separating the View code you have several advantages:

  • Reduction of network traffic
  • Reduced application server load
  • More dynamic and fluid navigation
  • Independence between Front-End and Back-End teams that only need to establish the roles and signatures of the methods that will be exposed

Frameworks

Among these frameworks I can quote:

Knockoutjs


It is a Viewmodel Model View framework that provides Two-Way binding between DOM and Viewmodel in javascript

Causes the DOM to update when there is an update in Viewmodel and updates the Viewmodel automatically when there is a change in the DOM

I have a few things delayed here, so finish add more to the answer with the other frameworks and examples

Emberjs


Ember.js is a Javascript framework for client-side web page development based on the MVC architecture. It allows you to create SPA (Single Page Applications) in a scalable way, incorporating many features as well as self-upgradable templates based on Handlebars.js

Angularjs

Angularjs is a MVW (Model View Whatever) framework that allows you to use (to be continued...)


Backbonejs


Browser other questions tagged

You are not signed in. Login or sign up in order to post.