1

I heard of mvc in javascript many times,however I have no idea about how the mvc work in js.

Since I have used the goolge map v3,and I found the MVCObject.

It seems that this is a helper class used for register and listener the property chang event of the object.

I thinks this should be the "Model", Howver I have not found the "MVCView" there.

I am really confused with that.

Anyone can give me more details?

4
  • Do you specifically want to know what MVC is within the context of the Google maps API? Or more generally MVC in the context of Javascript? Commented Nov 25, 2011 at 14:12
  • blog.mridey.com/2010/03/maps-javascript-api-v3-more-about.html Commented Nov 25, 2011 at 14:16
  • 1
    See ligament.js. Commented Nov 25, 2011 at 14:25
  • You probably need two different questions then, one that focuses on Google maps, and the other more general. Actually, I would be surprised if the second has not already been answered. Commented Nov 25, 2011 at 16:22

2 Answers 2

1

In javascript the view is mostly some html template that is rendered by some view class in js. The model is a class that is bound to that view so that, when it renders, the data from that model is being loaded on the correct positions in the templates. Take a look at backbone.js for example.

Sign up to request clarification or add additional context in comments.

Comments

0

Here's a brief overview at a high level on how the MVC Pattern works:

Controller:

  1. Listens on some kind of interaction/event stream.
  2. Controller can send the model that type of interaction/event.
  3. Controller can also communicate with the the view.

Model:

  1. Models will listen in on the interaction/event from the controller.
  2. Is an abstraction of a data source.
  3. Handles data logic and manipulation.
  4. After it is done with logic, it then sends to controller which will then communicate with the view.

View:

  1. View can communicate with the controller.
  2. Knows how to render data from the Model to the browser visually.
  3. The Controller tells to View to do something with something from the Model.

A couple of things to note is that models can't communicate with views directly and vise versa. Only the controller can communicate with the view and model, so the controller acts as the delegator for the interaction/event retrieved from users interaction on the browser.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.