Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何重新创建表';jQuery的内容是什么?_Javascript_Jquery - Fatal编程技术网

Javascript 如何重新创建表';jQuery的内容是什么?

Javascript 如何重新创建表';jQuery的内容是什么?,javascript,jquery,Javascript,Jquery,我想动态刷新表中的内容。这里的代码只启动但不重新加载表 内容存储在“data”对象中,其值来自rest调用。这项工作没有任何问题 我遇到的问题是,当我第二次加载另一个“data”myDataGrid()函数时,该函数不起作用。我怎样才能刷新它?我是否应该以某种方式破坏这个物体 这来自主要的js代码: $('#DataTables_Table_1_wrapper').html(""); $('table[data-table-name="dt-testCells"]').myDataGrid({

我想动态刷新表中的内容。这里的代码只启动但不重新加载表

内容存储在“data”对象中,其值来自rest调用。这项工作没有任何问题

我遇到的问题是,当我第二次加载另一个“data”myDataGrid()函数时,该函数不起作用。我怎样才能刷新它?我是否应该以某种方式破坏这个物体

这来自主要的js代码:

$('#DataTables_Table_1_wrapper').html("");

$('table[data-table-name="dt-testCells"]').myDataGrid({
    'aoColumns': cols,
    'aaData': data
});
创建表格:

MyDataGrid.prototype = {

constructor: MyDataGrid,

init: function(type, element, options) {
  this.type = type;
  this.$element = $(element);
  this.name = this.$element.data('table-name');
  this.settings = this.getOptions(options);

  this.createTable(options);
},
createTable: function(options) {
  // Init the datatable
  this.$table = this.$element.dataTable(this.settings);

  // Row Selection
  this.$table.on('click', 'tbody tr', $.proxy(this.clicked, this));

}

我看到您正在使用DataTables(虽然这是一个要点,但您没有提到),它是为ajax调用和表刷新而设计的。查看文档中来自ajax的数据:什么不起作用?没有显示有关加载新文件的内容data@charlietfl数据已正确加载且位于“数据”对象中。它第一次正确地创建了表。但即使正确加载了数据对象,也不是第二次。我的理论是它第二次、第三次等不会进入myDataGrid({})内部。@JeremyThille我会检查的,谢谢。