Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If I did a `bind(this)` in a jQuery event handler, I could never access the item that was being iterated, or the event was raised for... My problem with `this` in jQuery is that it's context that isn't passed.

    $('#foo').click(function(foo,event){ ... });
    $('#foo .item').each(function(item,index){...});
Is more sensical than...

    $('#foo').click(function(event){ var foo = $(this); ...})
    $('#foo .item').each(function(index){ var item = $(this); }
With jQuery, I couldn't use a function that was bound to an object.

    $('#foo').bind('foo',myContextObject.handleFoo.bind(myContextObject));
The binding/pattern just blows up, and handleFoo can't get to the foo instance... It's just really sloppy in my mind to change the context of functional expressions that way. Don't get me wrong, I really like a lot of what jQuery has done, and it's better than what came before it, I just find that using the this context removes a lot of options.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: