2013-04-18 54 views
-1

我得到這個消息沒有方法:我收到此消息「對象[對象的對象]具有‘上’

‘對象[對象的對象]具有‘上’’

沒有方法代碼

$(window).on('resize', function() { 
    self.setDimensions(); 
}); 

我能做些什麼? 我已經有jQuery的1.9 ...

+0

http://stackoverflow.com/questions/10912346/uncaught-typeerror-object-object-object-has-no-method-on –

+0

HTTP ://stackoverflow.com/questions/15519177/uncaught-typeerrorobjectobject-object-has-no-method-on –

+4

而且它是正確的版本? 'on'是1.7以上。 –

回答

1

確保你至少使用jQuery版本1.7

在1.7之前,您可以用替換爲.bind()(如果您不使用事件委託)。

最好的可能是你升級到最新的jQuery版本 - 1.9 ATM。

0

如果您已經包含最新版本的jQuery,並且它仍然說沒有on,那麼這意味着some other library is overwriting $。爲了解決這個問題,試試這個:

$.noConflict(); 
jQuery(document).ready(function($) { 
    // Use $ here 
    var self = mysterious(); 
    $(window).on("resize", function(){ 
     self.setDimensions(); 
    }) 
}); 

http://jsfiddle.net/DerekL/SUBGD/