【问题标题】:Can I use row.add as the InvokeCommand method?我可以使用 row.add 作为 InvokeCommand 方法吗?
【发布时间】:2017-10-31 22:23:48
【问题描述】:

在 Drupal 8 中,我想在 ajax 回调中向我的表中添加一个新行。

   $jQuery=new InvokeCommand('#scanned-vouchers', 'row.add', 
    array('','','','','',''));
   $ajax_response->addCommand($jQuery);

1) 文档说 InvokeCommand 支持简单的 jQuery 命令,例如adClass() 等如果 row.add 是可以接受的,我如何通过参数 3 传入列值?

2) 如果没有,考虑到我使用的是 jQuery Databale,我还可以使用什么其他方法在 ajax 回调中向表中添加一行?

TIA

以法莲

【问题讨论】:

    标签: jquery ajax drupal jquery-plugins


    【解决方案1】:

    我决定使用与 Drupal/core/Ajax 中其他文件相同的结构创建一个 DataTableCommand.php 文件。这个文件是我用我的自定义模块保存的。

    我破解了 misc/ajax.js 来处理 ajax 响应。 [不理想,但时间紧迫,现在 - 如何正确地做到这一点]。 现在:-

       $jQuery=new DataTableCommand('#abc', 'row', 'add', 
        array(col1, col2, col3, col4, col5, col6));
       $ajax_response->addCommand($jQuery);
    

    按预期添加一行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      • 2010-11-04
      • 1970-01-01
      • 2017-10-26
      • 2023-04-01
      • 2015-12-29
      • 1970-01-01
      相关资源
      最近更新 更多