Javascript 在<;中呈现数据表后,Jquery数据表功能不适用;f:ajax>;

Javascript 在<;中呈现数据表后,Jquery数据表功能不适用;f:ajax>;,javascript,jquery,jsf,Javascript,Jquery,Jsf,下面是jquery脚本 <script type="text/javascript" charset="utf-8"> var oTable; $(document).ready(function() { oTable = $('#example').dataTable({

下面是jquery脚本

 <script type="text/javascript" charset="utf-8">
                var oTable;
                               $(document).ready(function() {
                                    oTable = $('#example').dataTable({   
                                    "bJQueryUI": true,
                                    "sPaginationType": "full_numbers",
                                    "bRetrieve": true
                                       } );
                               } );

                               function datatable()
                               {
                                  oTable.fnDestroy();                                                                            
                                   oTable = $('#example').dataTable({
                                    "bJQueryUI": true,
                                    "sPaginationType": "full_numbers",
                                   "bRetrieve": true
                                     } );
                               }
            </script>
这是按钮点击代码

<h:commandButton value="Register" action="#{employeeListBean.register}" id="register" style="display: none" onclick="alert('asdsa')" >
                                <f:ajax execute="userId password empName Address gender mobNo loginname"  render=":example"/>
                            </h:commandButton>


当我单击该按钮时,编辑成功且datatable也处于立即渲染状态,问题是在渲染datatable之后,jquery datatable功能未应用于该表。

您需要在ajax事件渲染时重新应用该表()

添加此代码

$(window).load(function() {
    jsf.ajax.addOnEvent(function (data) {
        if (data.status === "success") {
            oTable = $('#example').dataTable({   
                     "bJQueryUI": true,
                      "sPaginationType": "full_numbers",
                       "bRetrieve": true
             } );
        }
    }
});

如果您查看带有firebug的表,id是“example”?但仍然存在一个问题,即旧数据表的页眉和页脚仍在保留,如果没有我建议的添加,旧数据表的页眉和页脚是否仍在保留?
$(window).load(function() {
    jsf.ajax.addOnEvent(function (data) {
        if (data.status === "success") {
            oTable = $('#example').dataTable({   
                     "bJQueryUI": true,
                      "sPaginationType": "full_numbers",
                       "bRetrieve": true
             } );
        }
    }
});