On a project using Spring MVC 4.0.6, Dandelion Datatables 1.1.0 with Dandelion Datatables Jsp 1.1.0, I have two jsps:
JSP1(simplified)
<%@ 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(simplified)
<%@ 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>
THE PROBLEM
The actual problem is that the first time JSP1
is loaded, the table's configuration is correctly done. But, when the button is clicked and the jquery.load()
gets executed the table's configuration is the default's one instead of the one I specified.
This is actually happening in several parts of the application when loading tables using JQuery.