![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
backbone.d3view
Advanced tools
A drop-in replacement for Backbone.View that uses only D3 DOM methods for element selection and event delegation. It has no dependency on jQuery.
NOTE: Backbone.D3View relies on at least version 1.2.0 of Backbone. Backbone 1.1.2 is not compatible with Backbone.D3View.
Load Backbone.D3View with your favorite module loader or add as a script tag after you have loaded Backbone and D3 in the page. Wherever you had previously inherited from Backbone.View, you will now inherit from Backbone.D3View.
var MyView = Backbone.D3View.extend({
initialize: function(options) {
// ...
}
});
As an alternative, you may extend an existing View's prototype to use D3 methods, or even replace Backbone.View itself:
_.extend(Backbone.View.prototype, Backbone.D3ViewMixin);
var MyView = Backbone.View.extend({
initialize: function(options) {
// ...
}
});
Delegation:
var view = new MyView({el: '#my-element'});
view.delegate('click', view.clickHandler);
Undelegation with event names or listeners,
view.undelegate('click', view.clickHandler);
view.undelegate('click');
View-scoped element finding that returns a NodeList:
view.$('.box')[0].classList.remove('active'); // for one matched element
// for multiple matched elements
_.each(view.$('.sidebar'), function(el) {
el.classList.add('active')
});
var fields = _.invoke(view.$('.field'), 'innerHTML');
View-scoped element finding that returns a d3 selector:
var Graph = Backbone.D3View.extend({
tagName: 'svg',
render: function() {
var node = this.$$(".node")
.data(bubble.nodes(classes(root))
.filter(function(d) { return !d.children; }))
.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
}
});
Direct reference to the D3 selection:
var Graph = Backbone.D3View.extend({
el: '#graph',
initialize: function() {
this.d3el.classed({'foo': true, 'bar': false});
}
});
The test suite includes the original Backbone.View QUnit conformance tests as well as a suite of Backbone.D3View-specific tests in mocha.
$el
property no longer exists on Views. Use el
instead. You may also
use the d3el
property for the reference to the D3 selection.$
method returns a NodeList instead of a jQuery context. You can
iterate over either using _.each
.FAQs
A Backbone View powered by D3 DOM wrapper
We found that backbone.d3view demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.