jQuery: why does my live() handler declaration error out when the analogous click() one doesn't?
- by Jason
I have the following in a javascript file (using jQuery as well):
$(function(){
$('#mybutton').live('click',myObject.someMethod);
});
var myObject = {
someMethod: function() { //do stuff }
};
I get a js error on pageload that says "myObject isn't defined". However, when I change the event handler in the doc.ready function to:
$('#mybutton').live('click', function(){ myObject.someMethod(); });
it works! I have code structured like the first example all over my codebase that works. W T F??