如何重绘或销毁我在xhtml中声明的数据表。我尝试了一切,但它不起作用。在JSF中操作JQuery中的DataTable
这是我的数据表:
<h:dataTable id= "book" var="book" value="#{bean.booksByAuthor}" rowClasses="even-row,odd-row">
<h:column>
<f:facet name="header">Title</f:facet>
<h:outputText value="#{book.title}" class=""/>
</h:column>
<h:column>
<f:facet name="header">ISBN</f:facet>
<h:outputText value="#{book.ISBN}"/>
</h:column>
<h:column>
<f:facet name="header">Price</f:facet>
<h:outputText value="#{book.price}"/>
</h:column>
<h:column>
<h:commandButton value="Buy" action="buyItem">
<f:param name="book2Buy" value="#{book.ISBN}" />
</h:commandButton>
</h:column>
</h:dataTable>
而且这是我正在试图访问它在我的脚本:
<script>
function change() {
event.preventDefault();
$('#f:\\book').DataTable().clear();
$('#f:\\book').DataTable().destroy();
}
</script>
这是我进口:
<script type="text/javascript" src="scripts/jquery-3.2.1.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.12.1/jquery-ui.js"></script>
<!-- Data Table-->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jq-2.2.4/dt-1.10.15/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/jq-2.2.4/dt-1.10.15/datatables.min.js"></script>
我甚至尝试访问此表,如$("$book)
,并致电html
或append
它。但没有任何工作。我甚至没有任何错误。
任何建议/建议?
首先阅读[如何使用jQuery选择JSF组件?](http://stackoverflow.com/questions/7927716/how-to-select-jsf-components-using-jquery) –