weixin_33705053 2012-04-17 16:23 采纳率: 0%
浏览 28

jQuery UI选项卡和数据表

I am trying to display a DataTable inside a Jquery Tab that is loaded through AJAX. When I open the page in a browser it shows fine but in AJAX case it is a just displayed inside the tab as a pure table. Is there something I am doing wrong or there is no possibility to do that? Thank you for responses.

As requested, here is the code. Loading libraries and CSS, convert unordered list to tabs

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/jquery-ui-1.8.18.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="js/ui-lightness/jquery-ui-1.8.18.custom.css" />
        <script>
        $(function() {
            $( "#tabs" ).tabs({
                ajaxOptions: {
                    error: function( xhr, status, index, anchor ) {
                        $( anchor.hash ).html(
                            "Some problem occured." +
                            "Probably the server is overloaded" );
                    }
                }
            });
        });
        </script>

Actual tabs

<div id="tabs">
        <ul>
             <li><a href="picklists.php?id=1"><span>Ready to be Picked</span></a></li>
             <li><a href="picklists.php?id=2"><span>Shipping Ready</span></a></li>
             <li><a href="picklists.php?id=3"><span>Picklists in Proforma</span></a></li>
             <li><a href="picklists.php?id=4"><span>Picklists in Invoice</span></a></li>
             <li><a href="picklists.php?id=5"><span>Picklists Shipped</span></a></li>
        </ul>
</div>

Then, picklist.php file that is loaded through AJAX. I will skip the code, just w=show the actual output

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
      <script src="js/jquery-ui-1.8.18.custom.min.js"></script>
      <link rel="stylesheet" type="text/css" href="js/ui-lightness/jquery-ui-1.8.18.custom.css" />
<table id="rows">
          <thead>
              <tr>
                  <td>
                  Invoice no.
                  </td>
                  <td>
                  Company
                  </td>
                  <td>
                  Items
                  </td>
                  <td>
                  Payment
                  </td>
              </tr>
          </thead>
          <tbody>
<tr>HERE COMES SOME INFORMATION</tr>
          </tbody>
      </table> <script language="JavaScript"> $(document).ready(function(){
 $('#rows').dataTable(); });
</script>

If I navigate to the page directly - it is fine. If I load it in a tab then it is just plain table

  • 写回答

2条回答 默认 最新

  • weixin_33674976 2012-04-18 21:30
    关注

    The problem is when you fire $('#rows').dataTable();

    You try to do it in $(document).ready but that's already come on gone by the time your ajax fires off. What you probably need to do is put $('#rows').dataTable(); in the callback for the when tab is redrawn after the ajax.

    If its not working in load, then use a setTimeout to invoke it a second later and see what happens. If it's still not working then put it in the success callback of your ajax options and use the setTimeout trick again.

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题