Search code examples
javascripttwitter-bootstrapbootstrap-table

bootstrapTable doesn't refresh with the newly created json


Everything worked fine until we transfered the app to new domain. Now it simply doesn't refresh the table with newly generated json.

$('input[name^=\"tbl-\"]').on('change', function() {
        let elem = $(this)
        $.post(
            '/analytics/admin/site/index',
            {index: $(this).data('index'), value: $(this).val()}
        )
        .done(function(data){
            let table = elem.next('.example').find('table')
            table.eq(1).bootstrapTable('refresh')
        })
    })    

Refresh action is executed (the form blings when its refreshed also no errors in the console). Tried with console.log in the .done() and request are successful. No errors in the network tab as well.


Solution

  • Without seeing the markup for your table, it's hard to know how you're expecting to update the data contained therein. If you're expecting it to be filled with the data value that's returned from your POST, I think you'll need to set the data option:

        .done(function(data){
            let table = elem.next('.example').find('table')
            table.eq(1).bootstrapTable({data: data})
            table.eq(1).bootstrapTable('refresh')
        })
    

    See: https://examples.bootstrap-table.com/#welcomes/from-data.html

    If you're instead using the data-url attribute on your table, you may need to check to see if that URL is still valid with your new domain.