I'm getting some data from a node.js server that affects the classes of some of my elements.
$.get('/example', function (data)
{
//changes element 1 to .newclass from .oldclass
});
Unfortunately, event handlers outside of the get request do not recognize the updated class.
$('.oldclass').click(function ()
{
//affects both element 1 and 2
});
If I nest the click event handler inside the get, the problem no longer exists. I suspect this has something to do with asynchronous requests, but I'm not entirely sure. Can someone explain to me why this happens and how it can be resolved without nesting my code inside each and every get request?