首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法将jQuery表附加到我的表中

问无法将jQuery表附加到我的表中
EN

Stack Overflow用户
提问于 2016-01-09 15:46:17
回答 1查看 510关注 0票数 1

我下载了jQuery表,但我不能使用。我将JS文件添加到我的页面中:

代码语言:javascript
复制
<script src="../assets/jquery-tabledit-1.2.3/jquery.tabledit.js"></script>
    <script src="../assets/jquery-tabledit-1.2.3/jquery.tabledit.min.js"></script>
    <script>
        $('#sales_table').Tabledit({
            url: 'example.php',
            editButton: false,
            deleteButton: false,
            hideIdentifier: true,
            columns: {
                identifier: [0, 'id'],
                editable: [[2, 'firstname'], [3, 'lastname']]
            }
        });
    </script>

这是我的桌子

代码语言:javascript
复制
        <table id="sales_table" border="1">
        <tr>
        <td id="firstname" name="firstname">a</td>
        <td>a</td>
        </tr>
        </table>

但是什么都没发生,也不能编辑表格。任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-09 17:18:28

您对可编辑列使用了错误的索引值,还需要一个标识符列。对Tableedit的调用隐藏了标识符列。

您似乎也没有引用主要的jquery库(至少在您提供的示例中):JQuery

有关工作示例,请参见此:小提琴

如果要更新表并执行任何其他功能,则需要阅读文档:

表编辑文档

代码语言:javascript
复制
<table id="sales_table" border="1">
  <thead>
    <tr>
      <td>First name</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td id="identifier" name="identifier">1</td> 
      <td id="firstname" name="firstname">John</td>
    </tr>
  </tbody>
</table>

JQuery

代码语言:javascript
复制
$('#sales_table').Tabledit({
  url: 'example.php',
  editButton: false,
  deleteButton: false,
  hideIdentifier: true,
  columns: {
    identifier: [0, 'id'],
    //Note that I've modified the column index values.
    editable: [[1, 'firstname'], [2, 'lastname']]
  }
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34695512

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档