0
這是我的ExtJs組件。 一切正常完美......差不多所有東西都是。 我只是不明白爲什麼this.on('load', function (form,action) {})
不叫而對於this.on('actioncomplete', function (form,action) {});
相同的聲明被稱爲:ExtJS和事件監聽器:'load'未被調用。怎麼會?
DossierPanel = Ext.extend(Ext.form.FormPanel, {
closable: true,
autoScroll:true,
initComponent : function(){
this.id = 'id_dossier_'+this.id_dossier;
this.bodyStyle = 'padding:15px';
this.labelWidth = 150;
this.items = [{
layout:'column',
border:false,
autoHeight: true,
items:[{
columnWidth:.5,
layout: 'form',
border:false,
items: [{
xtype:'textfield',
fieldLabel: 'Civilite ',
name: 'CIVILITE',
readOnly: true
}]
},{
columnWidth:.5,
layout: 'form',
border:false,
items: [{
xtype:'textfield',
fieldLabel: 'Email ',
name: 'EMAIL',
vtype:'email',
anchor:'95%'
}]
}]
},{
xtype:'tabpanel',
plain:true,
activeTab: 0,
deferredRender: false,
defaults:{bodyStyle:'padding:10px'},
items:[{
title:'Détails personnels',
layout:'form',
autoHeight: true,
defaults: {width: '99%'},
defaultType: 'textfield',
items: [{
xtype:'datefield',
fieldLabel: 'Date de naissance ',
name: 'NAISSANCEJMA',
format:'d/m/Y'
}]
},{
title:'Adresse',
layout:'form',
autoHeight: true,
defaults: {width: '95%'},
defaultType: 'textfield',
items: [{
fieldLabel: 'Adresse 1 ',
name: 'ADRESSE1'
}]
},{
title:'Téléphone(s)',
layout:'form',
autoHeight: true,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'DescTelephone1 ',
name: 'DESCTELEPHONE1',
readOnly: true
}]
},{
title:'Divers',
layout:'form',
autoHeight: true,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'ReferenceExterne ',
name: 'REFERENCEEXTERNE'
}]
}]
}];
this.buttonAlign = 'left';
this.buttons = [{
text: 'Recharger',
handler: function() {
this.getForm().load({
url: '/w.php',
params: {
id_dossier: this.id_dossier
},
failure:function(form, action) {
handleAjaxError(action.response,'Refresh error');
}
});
},
scope: this
},{
text: 'Sauver',
handler: function() {
this.getForm().submit({
url: '/ws.php',
params: {
write: 1
},
waitTitle: 'Patientez',
waitMsg: 'Sauvegarde',
success: function (form, action) {
var b = Ext.util.JSON.decode(action.response.responseText);
if (b.success==true) {
if (b.msg) {
Ext.MessageBox.alert('Done!', b.msg);
}
else {
Ext.MessageBox.alert('Done!', 'Saved');
}
}
},
failure:function(form, action) {
handleAjaxError(action.response,'Refresh error');
}
});
},
scope: this
}];
//this.listeners = {
// actioncomplete: handleActionComplete,
// load: handleLoad
//};
this.on('load', function (a,b,c) {
console.log(a);
console.log(b);
console.log(c);
});
this.on('actioncomplete', function (form,action) {
if (action.type=='load') {
console.log('actioncomplete => action load');
}
});
this.on('load', function (form,action) {
if (action.type=='load') {
console.log('LOAAAAAD');
}
});
DossierPanel.superclass.initComponent.call(this);
console.log(this.events)
}
});
觀察仔細this.on()代碼上面探微:控制檯日誌只顯示「'actioncomplete = >行動負載'「,而不是'LOAAAAAD'。從我的pov這是不正常的。我錯過了什麼嗎?
非常感謝您
如果是這樣,我不明白爲什麼有一個事件與action.type =='加載'。我認爲(我認爲這很明顯):「如果在全局事件處理程序(」actioncomplete「)中有一個名爲」load「的事件,這意味着有一個實際的事件」加載「。您認爲什麼? – 2011-03-24 09:22:00
action.type是指加載或提交表單的操作,它與組件事件無關 – 2011-03-24 09:46:47
非常感謝,我的英語有點完美,所以我經常感到困惑在行動和事件之間。 – 2011-03-24 13:56:58