Jquery拼接html的table,在其中使用标签不起作用解决办法
Jquery拼接html的table,在其中使用<c:if>标签不起作用
我如下function是通过jquery调用后台方法,查询资料后,循环通过$.each拼接table显示出来。
在拼接html中,在其中使用如下标红的<c:if>标签,但是始终都不起作用。
我在function开头,alert(comm.subWorkStatus == '230002'); 为true,但是拼接的html始终不显示已经选中“已完成”,真的比较奇怪。
------解决方案--------------------
我如下function是通过jquery调用后台方法,查询资料后,循环通过$.each拼接table显示出来。
在拼接html中,在其中使用如下标红的<c:if>标签,但是始终都不起作用。
我在function开头,alert(comm.subWorkStatus == '230002'); 为true,但是拼接的html始终不显示已经选中“已完成”,真的比较奇怪。
- JScript code
//初始化 function initWorkDetailInfo(){ var workNo = '<%=request.getAttribute("workNo")%>'; var sIndex = 0; $.get("<%=request.getContextPath()%>/<%=PFMConstants.PFM_MODULE_WORKS_ASSIGN%>/initWorkDetailInfo.htm",//URL {workNo:workNo},//傳入的參數 function(data, textStatus){//回調方法 var workDetailLists = JSON.parse(data); var html = ""; if(workDetailLists.length > 0){ //隱藏列標題 document.getElementById("headTitle").style.display = ""; } $.each(workDetailLists,function(index,comm){ [color=#FF0000]alert(comm.subWorkStatus == '230002');[/color] html+="<tr class='table-odd-row' id='shihuangzhe'>" +"<td class='table-other-column'><a href='javascript:void(0)' onclick='remove(this,\""+workDetailLists[index].responsiblePersonAccount+"\", \""+workDetailLists[index].responsiblePerson+"\")'><img src='${ctx}/images/u78.png' width='16' height='16' border='0' alt='刪除'></a></td>" +"<td class='table-string-column'><input type='text' class='textbox_char_120' name='workDetailInfoList["+sIndex+"].responsiblePerson' value='"+workDetailLists[index].responsiblePerson+"' readonly='readonly'><input type='hidden' name='workDetailInfoList["+sIndex+"].responsiblePersonAccount' value='"+workDetailLists[index].responsiblePersonAccount+"'></td>" +"<td class='table-string-column'><input type='text' class='textbox_char_120' name='workDetailInfoList["+sIndex+"].subWorkName' value='"+workDetailLists[index].subWorkName+"'></td>" +"<td class='table-string-column'><input type='text' class='textbox_char_120' name='workDetailInfoList["+sIndex+"].subEstimateEffort' value='"+workDetailLists[index].subEstimateEffort+"'></td>" +"<td class='table-num-column'><select name='workDetailInfoList["+sIndex+"].subWorkStatus' class='dropdownlist'><option value='230001' <c:if test="${comm.subWorkStatus == '230001'}">selected</c:if>>未完成</option><option value='230002' [color=#FF0000]<c:if test="${comm.subWorkStatus == '230002'}">selected</c:if>[/color]>已完成</option></select></td>" +"<td class='table-string-column'><input type='text' class='textbox_char_120' name='workDetailInfoList["+sIndex+"].subComment' value='"+workDetailLists[index].subComment+"'></td>" +"</tr>"; }); $("#tab1 tbody").html(html); }); return false; }
------解决方案--------------------