【发布时间】:2013-05-03 17:23:25
【问题描述】:
所以我尝试调用这个方法:
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 = function(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(函数(){ 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('关闭', function( p ) { if(functionOnClose) {
alert("方法:"+functionOnClose); var substr=functionOnClose.match(/(([^)]*))/); 变量参数=''; if(substr!=null){ 参数=substr[1]; 参数="'"+参数+"'"; }
debugger;
if(window[functionOnClose]) {
window[functionOnClose](param);
}
}
});
【问题讨论】:
标签: javascript window