jQuery mobile 1.3.0:"Uncaught Error: no such method 'refresh' for table widget instance "

3.5k views Asked by At

I use jQuery mobile 1.3.0 release:"Uncaught Error: no such method 'refresh' for table widget instance " But the doc says it can be used:

Updates the labels in the cells.

$( myTable ).table( "refresh" );

How to solve the problem? Is there a way to make the labels in the cells refresh?

    <div data-role="content" >
        <table id="tableProp" data-role="table" data-mode="Reflow" class="ui-body-d ui-shadow table-stripe ui-responsive" data-column-popup-theme="a">
                                        <thead>
                      <tr class="ui-bar-d">
                        <th data-priority="2" style="text-align: center">Test1</th>
                        <th  style="text-align: center">Test2</th>
                        <th data-priority="3" colspan=2   style="text-align: center">Test3</th>
                      </tr>
                    </thead>
                    <tbody id="tbProp">


                    </tbody>
                  </table>
               <a href="javascript:clickBtn()">Table test</a>

    </div><!-- /content -->
</div><!-- /page -->
    <script>
    function clickBtn()
    {
        var tb = $('#tbProp'),
        newRow = '<tr><th style="text-align: center;vertical-align:middle">' + 'Test11' + '</th> <td style="text-align: center;vertical-align:middle">' + '23.3'+ '</td><td style="text-align: center;vertical-align:middle"><a href="#" data-role="button" data-mini="true">Test22</a></td><td style="text-align: center;vertical-align:middle"><a href="#popupLogin" data-rel="popup" data-position-to="window" data-role="button" data-mini="true">Test33</a></td></tr>',
         newBody = "";
        for (var i = 0,
        l = 6; i < l; i += 1) {
            newBody += newRow;
        }

        tb.empty()
          .append(newBody);

          $("#tableProp").table("refresh");
    }
    </script>
1

There are 1 answers

2
Gajotres On BEST ANSWER

Your table was created dynamically, because of that it first needs to be initialized before it can be refreshed:

$( myTable ).table().table("refresh");

EDIT :

Working example: http://jsfiddle.net/Gajotres/Zqy4n/

Instead of:

$( myTable ).table("refresh");

trigger:

$( myTable ).trigger('create');