我正在使用javascript来控制在ColdFusion中创建一个cfwindow对象。
cfwindow附加到一个窗体上,该窗体允许用户选择一个信号或多个记录,并将它们分配或取消分配给单个记录。
cfwindow中的大多数表单为用户提供了输入表单元素然后提交的能力,然后销毁窗口,刷新显示结果的父窗口。在我的示例中,用户可以在完成之前对窗口对象中的多个提交进行仔细研究。
流程如下:
assignment.
<代码>H 111父窗口刷新。H 212G 213/code>G 213/code>
现在,我什么都有了,但是4号在工作。该窗口确实会刷新;但是,它不会显示更改(赋值或未分配)记录。我确认了数据层工作,并对表进行了更改;但是,它不会显示给用户。
因此,我需要在表单的onSuccess控件方面提供一些帮助。顺便说一下,我用的是cfform。
这是我的代码样本。如果您查看addedit.cfm的底部,您将看到cfmodule的代码。此页面与cfassign.cfm相同。唯一的区别是,我创建了一个新表单,因为cfwindow不允许在父窗体和子窗体之间使用相同的表单(当cfmodule使用时)。
addedit.cfm
<!------------------------------------------------------------------属性------------------------------------------------------------------->
---> ---> Administration Information Course ID Date Record Created Created By Date Updated Updated By Training Course Information • Course Code • Course Title Course Description ( 200 Character Limit ) ---> • Category . . . Select From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Frequency . . . Select From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Status . . . Select From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Training Method . . . Select From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Duration Course Cost • Initial Required Yes No • Launch Required Yes No Comments ( 200 Character Limit ) function cleanup() { //when onHide, destroy the contents of cfwindow ColdFusion.Window.destroy('prerequisite',true); //reload the parent page to display changes window.location.reload(); } function showWin(id) { //do we have one? try {ColdFusion.Window.destroy('prerequisite',true); } catch(e) { } ColdFusion.Window.create('prerequisite','Assign Pre-requisites for #qryCourses.Course\_Title#','cfassign.cfm?id='+id,{height:400,width:1150,modal:false,refreshOnShow:true}); //Assign variable when getting window object ob=ColdFusion.Window.getWindowObject('prerequisite\_body'); //Command to force the center of the window ob.center(); //Cleanup the window when closed ColdFusion.Window.onHide('prerequisite',cleanup); } cfassign.cfm ---> <cfif StructKeyExists(form, "btnUnassignCourses") and StructKeyExists(form, "AssignedCourses") and len( form.AssignedCourses ) gt 0>
<!--- Remove courses as pre-requisites from the parent course. --->
<cfquery name="RemoveCoursePrerequisite" datasource="#Request.App.DSN#" >
</cfquery>
<cfelseif StructKeyExists(form, "btnAssignCourses") and StructKeyExists(form, "UnassignedCourses") and len( form.UnassignedCourses ) gt 0>
<!--- Add course as pre-requisites for the parent course. --->
<cfquery name="AddCoursePrerequisite" datasource="#Request.App.DSN#" >
</cfquery>
</cfif>
<table>
<tr>
<div class="ModuleFullName">
<td>
<div class="fieldWrapperControl">
<label>Assigned Courses (#qryAssignedCourses.Recordcount#)</label>
<cfselect
name="AssignedCourses"
style="font-size:.8125em; height:200px; width:500px;"
query="qryAssignedCourses"
display="Course_Description"
value="ID"
queryposition="below"
editable="no"
multiple="true">
</cfselect>
</div>
</td>
<div class="fieldWrapperButton">
<td style="vertical-align:middle;">
<cfinput type="submit" name="btnAssignCourses" value="<<" style="display:block;" />
<cfinput type="submit" name="btnUnassignCourses" value=">>" style="display:block;" />
</td>
</div>
<td>
<div class="fieldWrapperControl">
<label>Unassigned Courses (#qryUnassignedCourses.Recordcount#)</label>
<cfselect
name="UnassignedCourses"
style="font-size:.8125em; height:200px; width:500px;"
query="qryUnassignedCourses"
display="Course_Description"
value="Unassigned_ID"
queryposition="below"
editable="no"
multiple="true">
</cfselect>
</div>
</td>
</tr>
<tr>
<td colspan="3" style="font-size:.9em;"><label>** Press and hold down the Ctrl OR Shift key to select multiple courses.</label></td>
</tr>
</table>发布于 2011-05-04 11:49:09
我认为您应该在cfwindow中添加属性refreshonShow="true“。
发布于 2013-08-12 09:35:35
在这种情况下,我认为刷新显示不起作用,因为您希望在提交时刷新您的窗口。所以从子窗口调用一些函数。该子窗口的代码必须存在于父窗口的脚本部分。
在我的情况下,我用这种方式,希望这可能会有所帮助。
function test(name)
{
ColdFusion.Window.hide(name);
window.location.reload();
}因此,我在子窗口中给出了一个名为“隐藏窗口”的按钮,当单击该按钮时,test()函数将被激活,因为子窗口中有此代码。
onClick="javascript:test('#url.empname#')"https://stackoverflow.com/questions/4475792
复制相似问题