Backbone sample environment

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.1.7/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js"></script>

JavaScript

window.App = { Views: {} };

App.Views.SessionList = Backbone.View.extend({
    tagName: 'select',
   
    events: {
        'change': 'selectionChanged'
    },
   
    initialize: function () {
        _.bindAll(this, 'selectionChanged');
        this.render();
        $(this.el).trigger('change');
        console.log(this.el);
    },
    
    render: function () {
        $(this.el).append('<option value="foo">Option 1</option>');
        $(this.el).append('<option value="bar">Option 2</option>');                
        return this;
    },
   
    selectionChanged: function (e) {
        var value = $(e.currentTarget).val();
        console.log("SELECTED", value);
    }
});

var view = new App.Views.SessionList();
$("body").append(view.el);