A misunderstanding of how this javascript is working
<p>I bind an event to a channel on the client side that waits for a message from the server and triggers the anonymous function in a callback, passing the message data in the <code>thing</code> parameter.</p>

<pre><code>channel.bind('coordinates_sent', function(thing) {
     var x = thing.left;
     var y = thing.top;

     $(window).scroll(function(){
           alert(x + " " + y);
     });

     alert(x + " " + y);
});
</code></pre>

<p>The alert message outside of the <code>scroll</code> method works as expected. It alerts the new x and y coordinates of the data sent from the server right when the new message arrives. </p>

<p>However, the alert message inside the scroll message behaves differently from how I would expect it to. If one message has been sent to the event listener, then the alert correctly displays the x and y coordinates from that message every time I scroll. However, if another message comes in, the alert displays first the original x and y coordinates from the first message, and then a separate alert displays the x and y coordinates from the most recent message.</p>

<p>I'm having trouble understanding why this is happening.</p>
