JSFiddle - React, Tailwind, and code Playground
by Cody Lindley
HTML
<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/jquery-2.0.2.js"></script>
<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/lodash.underscore.js"></script>
<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/backbone.js"></script>
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<div id="myView"></div>
CSS
iframe {
height:103px !important;
}
JavaScript
var MyView = Backbone.View.extend({
events: {'click button': 'callRemove'},
callRemove: function () {
this.remove(); //removes view from DOM, cleans up events in DOM
console.log($('#myView').length); //verify its gone, logs 0
},
render: function () {
this.$el.html('<button>invoke remove()</button>');
return this;
},
initialize:function(){this.render();}
});
var myViewInstance = new MyView({el: '#myView'});