Backbone.js Testing Ground

by emgee

HTML

<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone.js"></script>
<div id="test">
    Test Content
</div>

JavaScript

var V = Backbone.View.extend({
    tagName: "li",
    id: "thing",
    className: "active",
    attributes: {
        "data-value": 12345
    }
});

var v = new V({});
$("body").prepend(v.el);

// attach to existing element
var v2 = new V({el: "#test"});
v2.$el.css("background-color", "CornflowerBlue");