Search code examples
javascriptjquerytwitter-bootstrapbootstrap-table

Refreshing a Bootstrap-Table Table with JavaScript Function


I have table built with Bootstrap-Table.

I am working on refreshing the data via Javascript. From the docs, it seems like I should destroy the table, then rebuild it.

I have successfully destroyed the table, but refreshing it does not and there are no errors in the console.

$(function () {
  $rebuild.click(function(){
      $('#table').bootstrapTable('load', data);
  });
});

http://jsfiddle.net/rcr909rx/3/

Documentation: https://github.com/wenzhixin/bootstrap-table/issues/320


Solution

  • You need to use the 'load' function. Destroy isn't required.

    Like:

    var newData = [
        {"name": "new data!"},
    ];
    
    $('#table').bootstrapTable('load', {
        data: newData
    });
    

    I updated your fiddle: http://jsfiddle.net/qxw5y72f/