JSFiddle - React, Tailwind, and code Playground

by Eric Howe

HTML

<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<script id="t" type="text/x-underscore">
    <ul>
        <% for(var i = 0; i < 50; ++i) { %>
            <li <%= i == 20 ? 'id="toScroll"' : '' %>><%= i %></li>
        <% } %>
    </ul>
</script>

CSS

#toScroll {
    background: #eee;
}

JavaScript

var V = Backbone.View.extend({
    initialize: function () {
        this.render();
        var _this = this;
        _(function() {
            $('html, body').scrollTop(_this.$("#toScroll").offset().top);
        }).defer();
    },
    render: function () {
        var t = _($('#t').html()).template();
        this.$el.html(t());
        return this;
    }
});
var v = new V;
$('body').append(v.el);