在我的xhtml頁面中,第一次頁面看起來不錯,但是當我點擊h:commandLink時發送ajax請求 當它重新加載頁面css和jquery沒有加載。所以顏色和表格視圖改變了。 我的表是:ajax調用後無法調用jquery
<table width="100%" cellspacing="1" cellpadding="1" border="0" class="role_detail_section">
<thead><tr>
<th>Relationship-Type Name</th>
<c:forEach items="#{manageRelationBean.languageList}" var="languageName" >
<th>#{languageName}</th>
</c:forEach>
<th>Edit | Deactivate</th>
</tr>
</thead>
<tbody>
<c:forEach items="#{manageRelationBean.languageRelList}" var="languageRelDTO">
<tr>
<td>
#{languageRelDTO.relationName}
</td>
<c:forEach items="#{languageRelDTO.languageList}" var="relationValues">
<td>#{relationValues.relationValue}</td>
</c:forEach>
<td>
<span><h:commandLink value="Edit" class="edit_icon" action="#{relationBean.editRelationByRelationType}" immediate="true" >
<f:setPropertyActionListener target="#{relationBean.relationType}" value="#{languageRelDTO.relationName}" />
</h:commandLink></span>
<span> </span>
<span><p:commandLink rendered="#{manageRelationBean.findRelationStatus(languageRelDTO.country.countryCode,languageRelDTO.relationName) eq 1}" value=" Activate " action="#{manageRelationBean.activateRelation(languageRelDTO.relationName)}" update="@form" process="@this" >
<f:setPropertyActionListener target="#{relationBean.relationType}" value="#{languageRelDTO.relationName}" />
</p:commandLink>
<p:commandLink rendered="#{manageRelationBean.findRelationStatus(languageRelDTO.country.countryCode,languageRelDTO.relationName) eq 3}" value=" Deativate " action="#{manageRelationBean.softDeactivateRelation(languageRelDTO.relationName)}" update="@form" process="@this">
<f:setPropertyActionListener target="#{relationBean.relationType}" value="#{languageRelDTO.relationName}" />
</p:commandLink>
</span>
</td>
</tr>
</c:forEach></tbody>
</table>
和jQuery爲表着色是爲了結合處理程序被運行時再生的元素
$(document).ready(function(){
$(".role_detail_section tr:odd").addClass("activity_white");
$(".role_detail_section tr:even").addClass("activity_blue");
});
請後生成的HTML功能和代碼AJAX呼叫。我的猜測是你需要將某些事件委託給某個地方。 –
['nnth-child()'](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child)[fiddle](http://jsfiddle.net/Hp2nq/ ) – Andreas