Get started with backbone-super CDN

MIT licensed

Backbone-super is a library that extends Backbone.js with additional features and functionalities.

Tags:
  • backbone
  • super

Stable version

Copied!

How to start using backbone-super CDN


// Include Backbone and Backbone-Super via CDN
const Backbone = require('https://cdn.jsdelivr.net/npm/[email protected]/backbone.min.js');
const BackboneSuper = require('https://cdn.cdnhub.io/backbone-super/1.0.4/backbone-super-min.js');
BackboneSuper(Backbone);

// Define a simple Backbone View
class MyView extends Backbone.View {
  constructor(options) {
    super(options);

    this.template = _.template($('#my-template').html());

    this.listenTo(this.model, 'change', this.render);
  }

  render() {
    this.$el.html(this.template(this.model.toJSON()));
    return this;
  }
}

// Define a simple Backbone Model
class MyModel extends Backbone.Model {
  defaults = {
    name: 'John Doe',
  };
}

// Initialize the model and view
const myModel = new MyModel();
const myView = new MyView({ model: myModel });

// Attach the view to the DOM
$('body').append(myView.el);

// Set some data on the model
myModel.set('name', 'Jane Doe');
Copied!
Copied!

All versions