简体   繁体   中英

Using MVC in Javascript without any server-side language?

I'm in the process of trying to wrap my head around using MVC and using it with javascript. I'll be making a mobile app with HTML5 and don't plan to use any server side languages only local storage.

How can this be achieved? I'm usually thrown off by the model since it relies on the back end language from my understanding.

The Model doesn't rely on the back end. MVC in conceptually simple:

  1. Controller gets request.
  2. Controller calls for Model to do all of the logic (be it database interaction, localStorage interaction of whatever)
  3. Model returns data to Controller .
  4. Controller calls View accordingly, and if needed, passes data from the Model .

This means, that Model doesn't have to use a server side language, it's a placeholder for the application logic.

There are multiple MV* frameworks available. You don't have to have server support to use them.

There are many more, but these three come to mind first. Enjoy

MVC development has nothing to do with server side scripting.

It only relate to the type of architecture you are taking to develop your application.

It only means you have Models, Views and Controllers. Models can be object generated from javascript which are used with the Views in order to render some data.

Controllers are there to hold the logic and behaviour between the view and the models.

Well that's a very basic overview, but by no means does MVC means backend services or ajax calls.

This article might help http://www.alexatnet.com/articles/model-view-controller-mvc-javascript

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