【问题标题】:Tabledit not sending post actionTabledit 不发送帖子操作
【发布时间】:2018-10-08 09:06:29
【问题描述】:

我最近在一个页面中插入了tabledit,我跟随了几个例子但是所有的插件都不发布,不发布任何东西都是空的,我不知道如何使帖子工作你可以帮我吗?

简单脚本:

     <table class='table'>
  <thead>
    <tr>
      <th>Id</th>
      <th>Firstname</th>
      <th>Lastname</th>
      <th>Email</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>Doe</td>
      <td>Doe</td>
      <td>john@example.com</td>
    </tr>
  </tbody>
</table>
<script>
  $('.table').Tabledit({
    url: 'index.php',
    columns: {
      identifier: [0, 'id'],
      editable: [
        [1, 'col1'],
        [2, 'col2'],
        [3, 'col3']
      ]
    }
  });
</script>

一切都很简单,我收到按钮但要保存和删除 ajax 中的帖子但没有没有表单数据的字段,我该怎么办?

【问题讨论】:

    标签: javascript bootstrap-4 tabledit


    【解决方案1】:

    您需要在相关单元格中添加一些代码:

    <td class='tabledit-view-mode' style='cursor: pointer; background-color: #DEE1E8;'>
    <span class='tabledit-span' style='display: inline;'>YOUR CELL DATA</span>
    <input name='VAR_NAME' disabled='' class='tabledit-input form-control input-sm' style='display: none;' type='text' value='YOUR CELL DATA'></td>
    

    当您单击 Tabledit 时,它会将显示更改为输入,这样您就可以获得变量。

    【讨论】:

    • 我向你保证,即使没有 html 输入类型的文本,它也可以工作,它会自动生成。谢谢你的回答很慷慨
    【解决方案2】:

    您只是缺少 Tabledit 定义中的处理程序声明。

    documentation中有例子。

    我已经为你添加了它们。

    $(document).ready(function() {
    
        $('.table').Tabledit({
            url: 'index.php',
            columns: {
                identifier: [0, 'Id'],
                editable: [
                    [1, 'Firstname'],
                    [2, 'Lastname'],
                    [3, 'Email']
                ]
            },
            onSuccess: function(data, textStatus, jqXHR) {
                // deal with success there
            },
            onFail: function(jqXHR, textStatus, errorThrown) {
                // deal with errors there
            },
            onAjax: function(action, serialize) {
                // open your xhr here 
                console.log("on Ajax");
                console.log("action : ", action);
                console.log("data : ", serialize);
            }
        });
    
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery-tabledit@1.0.0/jquery.tabledit.min.js"></script>
    <table class='table'>
       <thead>
          <tr>
             <th>Id</th>
             <th>Firstname</th>
             <th>Lastname</th>
             <th>Email</th>
          </tr>
       </thead>
       <tbody>
          <tr>
             <td>1</td>
             <td>Doe</td>
             <td>Doe</td>
             <td>john@example.com</td>
          </tr>
       </tbody>
    </table>

    【讨论】:

    • 正是由于您的支持和您的 JavaScript 使我从一个黑色的周末中拯救了我,这正是我开始取得小胜利的原因。我不知道如何的 .js 文件以及源代码中的脚本是错误的。 ..非常感谢你的研究。再次感谢您
    • 对不起,但是......我不明白,但有一个检查不要在离线时使用脚本......它只有在我使用在线版本时才有效,如果我尝试将它放在本地主机中不会post,只能在线使用吗?
    • 如果我尝试复制外部源
    • 对不起,我自己搞砸了,它消除了我所说的一切,再次非常感谢你
    猜你喜欢
    • 2017-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多