在使用Spring MVC 4.0.6,Dandelion Datatables 1.1.0和Dandelion Datatables Jsp 1.1.0的项目中,我有两个jsps:
JSP1 (简化的)
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
<form:form id="contractForm" class="form-horizontal" action="create"
method="POST" modelAttribute="contractForm" novalidate="novalidate">
<label for="legalIdentifier">
<span>*</span> <fmt:message key="customers.cu.form.legal.id" />:
</label>
<form:input type="text" id="legalIdentifier" path="legalIdentifier" required="true"/>
<span class="btn btn-success" id="nifSearch">
<i id="searchIcon" class="fa fa-search"></i>
</span>
<div id="block_addresses_table">
<!--At first the table will be empty-->
<jsp:include page="jsp2.jsp" />
</div>
</form>
<script type="text/javascript">
$(document).ready(function(){}
$('#nifSearch').click(function(){
$(this).button('loading');
// find customer returns jsp2.jsp with data
$('#block_addresses_table').load('findCustomer','nif=' + $('#legalIdentifier').val(),
function(response, status) {
$('#nifSearch').button('reset');
}
);
});
</script>
JSP2 (简化的)
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
<datatables:table id="addressesList" data="${contractForm.customer.addresses}" row="address" pagingType="bootstrap_simple" dom="tp" sortable="false">
<datatables:column titleKey="customers.cu.form.address" property="completeAddress" />
</datatables:table>
问题
实际问题是第一次加载JSP1
时,表的配置正确完成。但是,当点击按钮并执行jquery.load()
时,表格的配置是默认配置,而不是我指定的配置。
当使用JQuery加载表时,实际上在应用程序的几个部分中发生了这种情况。