嗨,我有一個名爲taskReminder的頁面呈現兩個模板:任務1和提醒1。該任務的複選框勾選後,應重新填充/更新任務列表。一切工作正常,但我似乎無法理解的是爲什麼任務框更新並顯示其中的整個頁面。總結:整個頁面有一個任務框架,它也顯示了它的整個頁面(像以前一樣!) 我重新設計了html,重新評估了我的remotefunction,我也嘗試在提醒框架內放置一個diff複選框 - 當勾選時,它會更新任務框內的提醒列表,其中包含整個頁面,而不是他自己的框架列表。爲什麼我的Grails複選框onclick遠程函數ajax調用顯示更新錯誤?
在第一負載,複選框不點擊 - 顯示精細
當複選框被選中和任務框向下滾動,注意提醒框也有或整個頁面
這是爲什麼呢? 我的代碼: 爲taskreminder架
<%@ page import="com.irondata.icmgrails.constants.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="main" />
<style type="text/css">
body {background-color:#EEF2F7;}
</style>
<script type="text/javascript" language="javascript" src="${resource(dir:'js',file:'icmutilities.js')}"></script>
</head>
<body role="main">
<g:form>
<g:hiddenField name="caseId" value="${cmCaseInstance?.id}" />
<div class="body" role="article">
<h1>Tasks and Reminders</h1>
<br />
<br />
<div id="tasks">
<div class="summary">
<div class="summaryHeader">
<div class="summaryHeaderLeft">Tasks</div>
<div class="summaryHeaderCenter"> </div>
<div class="summaryHeaderRight"> </div>
</div>
<div class="gadgetShort">
<div>
<g:checkBox name='test' onclick="${remoteFunction(action:'workCategory', params:'\'completed=\'+ this.checked + \'&caseId=\' + caseId.value', update:[success:'divTasks', failure:'divTasks']) }" value="${false}"/>
</div>
<div id="divTasks">
<g:render template="taskList" model="['taskInstanceList': taskInstanceList, 'taskInstanceTotal': taskInstanceTotal, 'cmCaseInstance':cmCaseInstance]"/>
</div>
</div>
</div>
</div>
<div id="reminders">
<div class="summary">
<div class="summaryHeader">
<div class="summaryHeaderLeft">Reminders</div>
<div class="summaryHeaderCenter"> </div>
<div class="summaryHeaderRight"> </div>
</div>
<div class="gadgetShort">
<div>
<span class="gadgetName">Reminder List</span><span class="gadgetNumber">${taskInstanceTotal}</span>
</div>
<div id="divReminders">
<g:render template="reminderList" model="['reminderList': reminders, 'reminderListTotal': reminderCount]"/>
</div>
</div>
</div>
</div>
</div>
</g:form>
</body>
</html>
任務列表&提醒列表是完全thesame所以我沒有把用於提醒列表中的代碼。
<span class="gadgetName">Task List</span><span class="gadgetNumber">${taskInstanceTotal}</span>
<table cellspacing="0" cellpadding="0" id="tasksTableGrails" class="icmSortableTable" summary="Tasks" >
<thead>
<tr>
<g:sortableColumn scope="col" property="activityDescrip" title="${message(code: 'taskByCase.description.label', default: 'Description')}" params="${flash}" />
</tr>
</thead>
<g:each in="${taskInstanceList}" status="i" var="taskInstance">
<tr class="${(i % 2) == 0 ? '' : 'altRowColor'}">
<td>${fieldValue(bean: taskInstance, field: "activityTypeIdActivityType.activityDescrip")}</td>
</g:each>
</table>
這裏是我的代碼背後:
def workCategory = {
def isCompletedTaskIncluded
flash.employeeId = params.employeeId
flash.caseId = params.caseId
def cmCaseInstance = CmCase.get(params.caseId as Long)
def employee = employeeService.getUserEmployee(session.currentUser.id)
def criteria = Task.createCriteria()
def query = {
eq ("cmCaseIdCmCase", cmCaseInstance)
or {
eq ("fromEmplIdEmployee", Employee.get(employee.id))
eq ("toEmplIdEmployee", Employee.get(employee.id))
}
if(params.completed=="false")
isNull("actCompDate")
}
def taskInstanceList = criteria.list(query)
def reminders = Reminder.createCriteria().list() {
createAlias("cmCaseIdCmCase", "cmCase")
isNull("cmCase.closedDate")
eq('employeeIdEmployee', employee)
eq("cmCaseIdCmCase", cmCaseInstance)
}
def taskCount = taskInstanceList.size()
def reminderCount = reminders.size()
render(view: "taskReminder", model: [taskInstanceList: taskInstanceList, taskInstanceTotal: taskCount, reminderList: reminders, reminderListTotal: reminderCount, cmCaseInstance:cmCaseInstance])
}
當您在工作類別的底部調用渲染(查看:「taskReminder」...)時,你爲什麼要發送taskList和提醒列表,如果你只想渲染其中的一個呢? – MBozic
,因爲我想渲染兩者。在一個頁面中應該同時呈現兩個幀。 – user742102