jQuery: why does my live() handler declaration error out when the analogous click() one doesn't?
Posted
by Jason
on Stack Overflow
See other posts from Stack Overflow
or by Jason
Published on 2010-05-05T23:37:12Z
Indexed on
2010/05/06
0:28 UTC
Read the original article
Hit count: 494
JavaScript
|jQuery
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??
© Stack Overflow or respective owner