所以我试图调用这个方法:
refreshMoradaLabel = function(idPlaceHolder) {...};
使用窗口对象:
窗口 [ refreshMoradaLabel('id') ] ();
但这似乎不起作用。只有当方法没有参数时。有没有办法使用window [ variable ] ()
语法?
编辑;
好的,这是代码:
moarada.jsp 具有以下方法的代码:
<c:set var="methodOnClose" value="refreshDynamicValues" />
<c:if test="${empty fieldInstance || (not empty fieldInstance && isTramitacao)}">
<c:set var="methodOnClose" value="refreshMoradaLabel(${dfieldId})" />
</c:if>
<a class="texto" href="#" onclick="editMoradaPopup('${dfieldId}','${methodOnClose}');" id="moradas_${dfieldId}"><img alt="${moradaDes}" src="${pageContext.request.contextPath}/images/icon/icon-pesquisa.png"></a>
window.refreshMoradaLabel = 函数(idPlaceHolder){
alert("label:" +idPlaceHolder);
if($F(idPlaceHolder) != '') {
//Update label
new Ajax.Updater(idPlaceHolder+'_label', 'moradaPopupLocaleAware.do2?method=getLabel',
{method: 'get', parameters: 'id='+$F(idPlaceHolder)});
}
};
window.editMoradaPopup=函数(idPlaceHolder,方法){警报(idPlaceHolder);Ext.onReady(function(){ action = "${pageContext.request.contextPath}/moradaPopupLocaleAware.do2"; action += "?method=edit&id="+$(idPlaceHolder).value;
action += "&idPlaceHolder="+idPlaceHolder;
action += "&savemorada=true";
action += "&window=winchoose";
return ExtWindowAll('${moradaDes}',action,'','html',true,true,true,650,400,true,true,'fit', method);
});
};
方法 ExtWindowAll 最终从另一个 js 文件调用代码,结果调用关闭窗口事件,方法名称(refreshMoaraLabel)的字符串包括可能的参数:
winchoose.on('close', function( p ) { if(functionOnClose) {
alert("method: "+functionOnClose); var substr=functionOnClose.match(/(([^)]*))/); 变量参数=''; if(substr!=null){ 参数=substr[1]; 参数="'"+参数+"'"; }
debugger;
if(window[functionOnClose]) {
window[functionOnClose](param);
}
}
});