An AMD compatible version of backbone-raphael by Tomas Alabes.
This extension enables you to add views to your backbone apps tweaking how Backbone and RaphaelJS handle event bindings.
- Install raphael-amd
bower install backbone.raphael-amd
(or your preferred installation method)- Setup your require.js config:
paths: {
'foo...': 'bar...',
'backbone': '../path/to/backbone',
'backbone.raphael': '../bower_components/backbone.raphael-amd/backbone.raphael'
}
- Then use backbone-raphael in place of Backbone when using require:
require([
'backbone.raphael',
'raphael'
], function (Backbone, Raphael) {
// Create a raphael instance
var paper = Raphael('paper', 500, 500);
// Create a Backbone RaphaelView
var TestView = Backbone.RaphaelView.extend({
render: function(){
var rect = this.options.paper.rect(50,50,50,50);
rect.attr('fill', '#00DD00');
}
});
// Create a new instance of the test view, and render
new TestView({ paper: paper }).render();
});
Licensed under the MIT license.