Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript MVC Framework + raphaelJS

I'm trying to make an app that has a client MVC architecture, but in addition to HTML templates, it has SVG elements as the View (I use raphael to manage this).

Is there any JavaScript MVC framework that works well with raphaelJS as the View?

In the case that there isn't, are there any suggested frameworks that could work well with it?

like image 371
talabes Avatar asked Apr 28 '12 17:04

talabes


People also ask

Which JavaScript Framework uses MVC?

Following are popular JavaScript MVC Framework. Backbone. js: Provides models with key-value binding and custom events, collections, and connects it all to your existing API over a RESTful JSON interface. AngularJS: A toolset based on extending the HTML vocabulary for your application.

What is JavaScript MVC framework?

MVC frameworks are libraries that can be included alongside JavaScript to provide a layer of abstraction on top of the core language. Their goal is to help structure the code-base and separate the concerns of an application into three parts: Model - Represents the data of the application.

Is there an MVC for JavaScript?

The MVC architecture is very useful in JavaScript as it offers more than allowing developers to create modular code. For instance, since the Model in MVC returns data without formatting, the same components can be called for use in different interfaces. This allows for code reusability.


1 Answers

Backbone.js is a simply MVC framework, it not limit which template engine to use but give the choice to yourself.

In backbone render function, it always generate HTML code from some JSON data like this:

render: function () {
    // use underscore as template engine
    this.el.innerHTML = _.template(TMPL_STRING).render(JSON_DATA);
}

Use RaphaelJS here is very easy:

initialize: function () {
    this.paper = Raphael(this.el, width, height);
},
render: function () {
    // use this.paper to render svg here
}
like image 173
Ethan Zhang Avatar answered Oct 14 '22 19:10

Ethan Zhang