简体   繁体   English

jQuery treeTable插件抛出错误“ TypeError:$(…).treetable不是函数”

[英]jQuery treeTable Plugin throwing error “TypeError: $(…).treetable is not a function”

Scenario: Consider the following in code html file: 场景:考虑代码html文件中的以下内容:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>jQuery treetable</title>
        <link rel="stylesheet" href="assets/css/screen.css" media="screen" />
        <link rel="stylesheet" href="assets/css/jquery.treetable.css" />
        <link rel="stylesheet" href="assets/css/jquery.treetable.theme.default.css" />
    </head>
    <body>
        <div id="main">
            <table id="tree">
                <tr id="node-1">
                    <td>Parent</td>
                </tr>
                <tr id="node-2" class="child-of-node-1">
                    <td>Child</td>
                </tr>
                <tr id="node-3" class="child-of-node-2">
                    <td>Child</td>
                </tr>
            </table>
        </div>
        <script src="assets/js/jquery.js"></script>
        <script src="assets/js/jquery-ui.js"></script>
        <script src="assets/js/jquery.treetable.js"></script>
        <script>
            $("#tree").treetable({ expandable: true }); 
        </script>
    </body>
</html>

All the resources/dependencies (js, css and image files) are loads perfectly with 200 HTTP Status (later on 304). 所有资源/依赖项(js,css和图像文件)均以200 HTTP状态(后来在304上)完美加载。

Issue: Is error in Firebug. 问题:是Firebug中的错误。 Below is the error from firebug console: 以下是来自Firebug控制台的错误:

TypeError: $(...).treetable is not a function
[Break On This Error] 
$("#tree").treetable({ expandable: true });

Links: 链接:

  1. Sources for plugin 插件来源
  2. Documentation and Demo/Examples 文档和演示/示例

Question: Does anyone got this issue & knows any solution? 问题:是否有人遇到此问题并且知道任何解决方案? Then please put some light on this it will be of great help. 然后,请对此进行一些说明,它将大有帮助。


Update 1: Even tried with following code: 更新1:甚至尝试使用以下代码:

 <script> $(document).ready(function () { $("#tree").treetable({ expandable: true }); }); </script> 


Update 2: Based on all the answers. 更新2:基于所有答案。

I tried with following code: 我尝试使用以下代码:

 <script> $(document).ready(function () { $("#tree").treeTable({ expandable: true }); }); </script> 

But no luck :-( 但没有运气:-(

And is the source example its just 't' not capital 'T'.( Link ) 并且是源示例,它只是“ t”而不是大写的“ T”。( Link

your methods is wrong. 您的方法是错误的。 Check the Docs for example . 以Docs为例 you need to use the lowercase for the method. 您需要对方法使用小写字母。

 $("#tree").treetable({ expandable: true });

Old reference provided in the documentation & installation steps ( link > 2.2 ) 文档和安装步骤中提供了旧参考资料( 链接> 2.2

2.2 step says that "Add src/javascripts/jquery.treeTable.js " 2.2步骤说“添加src / javascripts / jquery.treeTable.js

But it does not work and the working sample referring to different jquery.treeTable.js file on the server. 但是它不起作用,并且该工作示例引用了服务器上的其他jquery.treeTable.js文件。 Its correct in the GitHub scource code GitHub搜寻代码中正确

Other answers referred to code treetable() has to be like treeTable() . 引用代码treetable()其他答案必须类似于treeTable() But it didn't work. 但这没有用。 :-( :-(

Issue was : 2.2 step says that "Add src/javascripts/jquery.treeTable.js " 问题是: 2.2步骤说“添加src / javascripts / jquery.treeTable.js

Solution: Get the jquery.treeTable.js file from GitHub 解决方案:GitHub获取jquery.treeTable.js文件

Issue Raised on GitHub 在GitHub上引发的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM