#723

Simple test case for Backbone issues

by wookiehangover

HTML

<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone.js"></script>
<script src="https://getfirebug.com/firebug-lite.js"></script>

JavaScript

var counter = 0;

var handler = function(){
    console.log(++counter);
};

$('<div></div>').bind('event', function(){
    console.log("event 1: neseted binding");
  $(this).bind('event', handler);
})
.trigger('event') // doesn't call handler
.unbind()
.bind('event', function(){
    console.log("event 2: neseted unbinding");
  $(this).unbind('event', handler);
})
.bind('event', handler)
.trigger('event');  // calls handler === 1