JQuery tablesorter Uncaught TypeError:Object#<htmldocument>没有方法'ready'</htmldocument>

时间:2013-08-27 12:22:01

标签: javascript jquery symfony1

编辑3:现在正在运作。感谢@ Dimitar的建议,包括重新排序和apache重启看起来它现在已经解决了。谢谢你们。编辑2中显示的包含顺序是实际顺序。

编辑2:

检查文档我看到包括始终以相同顺序的位置,所以我重新排序了我的包含。现在没有错误,但它也不起作用。谁知道为什么?

新订单:

<?php use_helper('Javascript','Form') ?>
<?php use_javascript('toggleTabActive') ?>
<?php echo javascript_tag("toggleTabActive(15)"); ?>
<?php use_javascript('/sfProtoculousPlugin/js/prototype.js'); ?>
<?php use_javascript('/sfProtoculousPlugin/js/effects.js'); ?>
<?php use_javascript('/sfProtoculousPlugin/js/controls.js'); ?>
<?php use_javascript('jquery-1.3.2.min.js'); ?>
<?php use_javascript('jquery-latest.js'); ?>
<?php use_javascript('jquery.tablesorter.min.js'); ?>
<?php use_stylesheet('tablesorter/style.css') ?>

编辑1:关注@Dimitar建议我使用noconflict进行jquery。现在:

<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j(".urTable" ).tablesorter();
});
</script>

显示的错误是:

1:GET http://sdbweb/css/tablesorter/bg.gif 404 (Not Found)

2:Uncaught TypeError: Object #<Object> has no method 'dispatchEvent'

“1”必须是与tablesorter CSS包含的图像之一相关的一些路径问题。之后我会调查它。

“2”与prototype.js有关。我猜它也使用JQuery,因此可能会在那里引发冲突。有关解决此冲突的最佳做法的任何建议吗?

ORIGINAL:

这是我第一次使用JQuery,很抱歉,如果我问的话很明显。

我刚刚开始一份新工作,我的老板让我对内部网络应用程序做了一些更改,我想在其中一个表格中添加排序功能。我发现了tablesorter,并且开始了。

现在不行,我不知道为什么。检查chromium javascript控制台将显示以下消息:Uncaught TypeError: Object #<HTMLDocument> has no method 'ready'

我已经搜索了类似的问题,通常是糟糕的JQuery包含或权限。我确定这不是权限,包括我不知道。

该应用使用symfony 1.2,现在无法升级。

我的标题如下:

<?php use_helper('Javascript','Form') ?>
<?php use_javascript('toggleTabActive') ?>
<?php use_javascript('jquery-latest.js'); ?>
<?php use_javascript('jquery.tablesorter.min.js'); ?>
<?php use_javascript('jquery-1.3.2.min.js'); ?>
<?php echo javascript_tag("toggleTabActive(15)"); ?>
<?php use_javascript('/sfProtoculousPlugin/js/prototype.js'); ?>
<?php use_javascript('/sfProtoculousPlugin/js/effects.js'); ?>
<?php use_javascript('/sfProtoculousPlugin/js/controls.js'); ?>
<?php use_stylesheet('tablesorter/style.css') ?>

<script type="text/javascript">
$(document).ready(function(){
$(".urTable" ).tablesorter();
});
</script>

表格:

<table class="tablesorter urTable" width="100%" cellspacing="0" cellpadding="1" border="0">
        <thead>
        <tr class="collection-as-table">
          <th class="collection-as-table"></th>
          <th class="collection-as-table">Access</th>
          <th class="collection-as-table">Name</th>
          <th class="collection-as-table">Activity</th>
          <th class="collection-as-table">Machine</th>
          <th class="collection-as-table">Activation Date</th>
          <th class="collection-as-table">Mail</th>
          <th class="collection-as-table">UR</th>
        </tr>
        </thead>
        <tbody>
        [...]
        </tbody>
      </table>

任何见解,建议,教程,解释......?

感谢您的时间。

1 个答案:

答案 0 :(得分:0)

您似乎正在加载Prototype并且它会覆盖$。尝试删除其中一个或查看jQuery的noconflict mode

从链接:

var $j = jQuery.noConflict();
// $j is now an alias to the jQuery function; creating the new alias is optional.

$j(document).ready(function() {
    $j(".urTable" ).tablesorter();
});
相关问题