ColdFusion.Window.create 不刷新弹出窗口 window
ColdFusion.Window.create not refreshing the pop up window
我正在打开 window 以通过 Coldfusion.Window.Create 编辑项目。当我点击不同的 "edit" 链接时,window 总是显示我编辑的第一个项目,而不是我点击的那个。出于某种原因,弹出窗口 window 没有在每次调用中刷新。
这是我的 cfm 代码:
<cfoutput query="getSavedSelections">
<table class="mytableb" >
<tr>
<td class="mylistb" style="width:178px;" valign="top">
#getSavedSelections.SavedSelectionExportName#
</td>
<td class="mylistb" style="width:130px;" valign="top">
(<a onclick="EditSurveyExport(#getSavedSelections.SavedSelectionExportId#,'#scope#')" style="cursor: pointer;cursor:hand;">Edit</a> | <a onclick="ConfirmExportDeletion('#scope#',#pgmid#,#getSavedSelections.SavedSelectionExportId#,'#surveyAliasname#','#getSavedSelections.SavedSelectionExportName#','csv');" style="cursor: pointer;cursor:hand;">Delete</a>)
</td>
</tr>
</table>
</cfoutput>
这是打开和关闭 window 的 javascript 代码:
function EditSurveyExport(SavedSelectionID,passedScope)
{
console.log(SavedSelectionID);
ColdFusion.Window.create("SavedSelectionEditingWindow","Edit Saved selection","index.cfm?event=survey.editexportwithid&SavedSelectionID="+SavedSelectionID+"&passedscope="+passedScope,{modal:true,width:500,height:700,center:true,draggable:true})
console.log('after create');
document.getElementById(ColdFusion.Window.getWindowObject("SavedSelectionEditingWindow").header.id).className = "windowHdr";
}
function CloseExportEditingWindow()
{
ColdFusion.Window.hide('SavedSelectionEditingWindow');
console.log('after closing');
}
我观察了控制台。仅在页面加载后第一次调用此 url:“http://localhost/index.cfm?event=survey.editexportwithid&SavedSelectionID=1029&passedscope=individual&_cf_containerId=SavedSelectionEditingWindow-body&_cf_nodebug=true&_cf_nocache=true&_cf_clientid=8BF05647C531DF1C34380F471DE37721&_cf_rc=0”。
然后我在控制台中只能看到id和'after create'。
我无法理解这背后的原因。谁能帮我理解为什么会这样?
我同意 Scott 的评论,您应该尝试使用较新的 JavaScript 库,而不是依赖 ColdFusion 为您做这件事。你最终会运行进入限制。
话虽如此,我认为问题在于您打开的每个 window 必须具有唯一的名称。否则代码将只打开现有的 window.
来自 the docs 关于 name
参数:
The name of the window. This attribute is required to interact with the window, including to dynamically show or hide it. If a window with the specified name exists, the function shows that window, and ignores the remaining parameters; otherwise, the name must be unique on the page.
在您的代码中创建的所有 windows 都将具有相同的名称; "SavedSelectionEditingWindow"。您需要为每个要打开的不同 window 创建唯一的名称。您可能只需将 SavedSelectionID
参数附加到名称(假设每个项目都是唯一的)。
首先,我要重申 Scott 和 Miguel 所说的话。如果不需要,请不要使用它。话虽如此,为了回答您的问题,您需要在重新创建 window 之前销毁它,以便获取 cfwindow 代码以重新加载内容。这是我用来执行此操作的函数:
var windowCleanup = function(id) {
try {
//Destroy the window if it still exists
ColdFusion.Window.destroy(id, true);
} catch(e) { }
}
这将彻底破坏之前的 window,然后创建新的。然后,每当您在 create()
语句之后创建一个新的 window、运行 时:
ColdFusion.Window.onHide(id, windowCleanup);
现在,任何时候 window 被隐藏,无论出于何种原因,它都会被正确销毁,您将为新的 create()
方法调用做好准备。
我正在打开 window 以通过 Coldfusion.Window.Create 编辑项目。当我点击不同的 "edit" 链接时,window 总是显示我编辑的第一个项目,而不是我点击的那个。出于某种原因,弹出窗口 window 没有在每次调用中刷新。
这是我的 cfm 代码:
<cfoutput query="getSavedSelections">
<table class="mytableb" >
<tr>
<td class="mylistb" style="width:178px;" valign="top">
#getSavedSelections.SavedSelectionExportName#
</td>
<td class="mylistb" style="width:130px;" valign="top">
(<a onclick="EditSurveyExport(#getSavedSelections.SavedSelectionExportId#,'#scope#')" style="cursor: pointer;cursor:hand;">Edit</a> | <a onclick="ConfirmExportDeletion('#scope#',#pgmid#,#getSavedSelections.SavedSelectionExportId#,'#surveyAliasname#','#getSavedSelections.SavedSelectionExportName#','csv');" style="cursor: pointer;cursor:hand;">Delete</a>)
</td>
</tr>
</table>
</cfoutput>
这是打开和关闭 window 的 javascript 代码:
function EditSurveyExport(SavedSelectionID,passedScope)
{
console.log(SavedSelectionID);
ColdFusion.Window.create("SavedSelectionEditingWindow","Edit Saved selection","index.cfm?event=survey.editexportwithid&SavedSelectionID="+SavedSelectionID+"&passedscope="+passedScope,{modal:true,width:500,height:700,center:true,draggable:true})
console.log('after create');
document.getElementById(ColdFusion.Window.getWindowObject("SavedSelectionEditingWindow").header.id).className = "windowHdr";
}
function CloseExportEditingWindow()
{
ColdFusion.Window.hide('SavedSelectionEditingWindow');
console.log('after closing');
}
我观察了控制台。仅在页面加载后第一次调用此 url:“http://localhost/index.cfm?event=survey.editexportwithid&SavedSelectionID=1029&passedscope=individual&_cf_containerId=SavedSelectionEditingWindow-body&_cf_nodebug=true&_cf_nocache=true&_cf_clientid=8BF05647C531DF1C34380F471DE37721&_cf_rc=0”。
然后我在控制台中只能看到id和'after create'。
我无法理解这背后的原因。谁能帮我理解为什么会这样?
我同意 Scott 的评论,您应该尝试使用较新的 JavaScript 库,而不是依赖 ColdFusion 为您做这件事。你最终会运行进入限制。
话虽如此,我认为问题在于您打开的每个 window 必须具有唯一的名称。否则代码将只打开现有的 window.
来自 the docs 关于 name
参数:
The name of the window. This attribute is required to interact with the window, including to dynamically show or hide it. If a window with the specified name exists, the function shows that window, and ignores the remaining parameters; otherwise, the name must be unique on the page.
在您的代码中创建的所有 windows 都将具有相同的名称; "SavedSelectionEditingWindow"。您需要为每个要打开的不同 window 创建唯一的名称。您可能只需将 SavedSelectionID
参数附加到名称(假设每个项目都是唯一的)。
首先,我要重申 Scott 和 Miguel 所说的话。如果不需要,请不要使用它。话虽如此,为了回答您的问题,您需要在重新创建 window 之前销毁它,以便获取 cfwindow 代码以重新加载内容。这是我用来执行此操作的函数:
var windowCleanup = function(id) {
try {
//Destroy the window if it still exists
ColdFusion.Window.destroy(id, true);
} catch(e) { }
}
这将彻底破坏之前的 window,然后创建新的。然后,每当您在 create()
语句之后创建一个新的 window、运行 时:
ColdFusion.Window.onHide(id, windowCleanup);
现在,任何时候 window 被隐藏,无论出于何种原因,它都会被正确销毁,您将为新的 create()
方法调用做好准备。