可变内部自定义函数
问题描述:
如何我可以在Ext.Msg函数内部访问下面的alRec变量,现在我无法访问。可变内部自定义函数
var alRec = allRecords[i];
prefFlag = true;
Ext.Msg.show({
title:'Error',
msg:"SOME MESSAGE",
buttons: Ext.Msg.OKCANCEL,
animEl: 'wId',
icon: Ext.MessageBox.ERROR,
fn: function(button,alRec) {
if(button=='ok')
this.onApply();
else {
alRec.reject();
return false;
}
},
scope:this
});
答
var alRec = ['a'];
Ext.Msg.show({
title:'Error',
alRec: alRec,
msg:"SOME MESSAGE",
buttons: Ext.Msg.OKCANCEL,
animEl: 'wId',
icon: Ext.MessageBox.ERROR,
fn: function(button){
console.log(this.alRec); //now its accesible
if(button=='ok')
this.onApply();
else
{
//sth to do
return false;
}
},
scope:this
});
使用this.alRec
,其中制定了 – prakashkadakol 2012-03-01 05:58:14