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?
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.
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.
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.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With