1

I am using jQuery 1.8 and have been getting this error on some pages when I use the .on() function. Other pages, seemingly doing the exact same thing -- attaching triggers to dynamically created elements, that I use do not generate this error:

Uncaught TypeError: Object #<Object> has no method 'on'

JS:

$(document).ready(function(){
    $(document).on("click","button.pagebutton",function() {
        $("div#pagesforreview").hide();
        jsD=Date();
        jsP=$(this).html();
        $("div#externpage").load("prexternpage.php",{d:jsD,p:jsP},function() {
            $("div#externpage").show();
            $("div#pageactions").show();
            jsNc=1;
            $("div#pagecomments").load("praddcomment.php",{d:jsD,nc:jsNc},function() {
            $("div#pagecomments").show();
            });
        });
    });
});

All dynamically generated 'pagebutton' buttons, don't trigger. And the error shows up. If I use the .live() method that is deprecated, no problems. But I prefer to use the proper new 1.8 non-deprecated method, if possible?


You can use xargs -L1 lsof -p to run lsof once per pid.

Even better: use lsof -c to list all open files from commands matching a specific pattern:

lsof -c bas # list all processes with commands starting with 'bas'
lsof -c '/ash$/x' # list all commands ending with 'ash' (regexp syntax)
4

2 回答 2

0

而是 $(document).ready(function(){ 在第一行写下这个: jQuery(document).ready(function($){ 它对我有用。

于 2014-01-17T14:28:47.650 回答
0

我发现我的头文件是从我的生产服务器而不是我的开发服务器(1.8 版)加载 jquery 库(1.6 版)......从而产生了问题。哦。感谢您的评论。

于 2012-09-18T20:37:36.357 回答