【问题标题】:can't attach jQuery tableditor into my table无法将 jQuery tableeditor 附加到我的表中
【发布时间】:2016-01-09 15:46:17
【问题描述】:

我下载了 jQuery tableeditor 但我不能使用。 我在页面中添加了 JS 文件:

<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>

这是我的桌子:

        <table id="sales_table" border="1">
        <tr>
        <td id="firstname" name="firstname">a</td>
        <td>a</td>
        </tr>
        </table>

但是什么也没发生,并且无法编辑表格。 任何帮助表示赞赏。

【问题讨论】:

  • 检查浏览器的开发者控制台并提供任何错误(如果有)可能会有所帮助。

标签: php jquery jquery-plugins


【解决方案1】:

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

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

查看此示例以获取工作示例: Fiddle

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

Tableedit Docs

HTML

<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

$('#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']]
  }
});

【讨论】:

  • 先生,您能帮我解决一下example.php吗?我遇到了麻烦,这是我们返回json_encode的普通php更新查询吗?
  • 您应该提出一个新问题,因为答案与当前问题没有直接关系。
  • 我问了一个新的这里是链接请帮助link[link]
  • 我对php不是很熟悉,所以你必须等待其他人回答。这个问题是我熟悉的jquery。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-09
  • 2022-06-28
  • 1970-01-01
  • 1970-01-01
  • 2016-04-04
  • 1970-01-01
  • 2022-10-24
相关资源
最近更新 更多