我正在尝试从ExtJS弹出窗口调用一个函数,但它没有识别该方法。我想我错过了范围。请看下面的代码并建议我哪里出错了。 在下面的代码部分中,handler:function()没有调用预期的方法。
Ext.define('App.controller.MakerController', {
extend : 'Ext.app.Controller',
models : [],
stores : [],
views : [ 'makertabpanel' ],
init : function() {
this.control({
'makertabpanel button[name= addNewUser]' : {
click : this.openDialog
},
'makertabpanel button[name= modifyUser]' : {
click : this.openmodifyDialog
}
});
},
openmodifyDialog : function() {
var userinfoGrid = Ext.getCmp('userinfogridID');
if (userinfoGrid.getSelectionModel().hasSelection()) {
var row = userinfoGrid.getSelectionModel().getSelection()[0];
console.log(row.get('id'));
var name = Ext.getCmp('usernameID').setValue(row.get('id'));
var name = Ext.getCmp('userFirstName').setValue(row.get('fname'));
var name = Ext.getCmp('userLastName').setValue(row.get('lname'));
}
this.openDialog();
},
openDialog : function() {
//var that = this;
var dialog = Ext.create('Ext.window.Window', {
title : 'Permission Uesr',
itemId : 'adduserpopup',
id : 'adduserpopup',
closeAction: 'hide',
modal : true,
width : 1000,
height : 400,
layout : {
type: 'vbox',
align: 'stretch',
padding: 5
},
resizable : false,
items : [ createuserinformation,itemselectorGrid],
buttons : [ {
text : 'Save',
id : 'okbutton',
handler: function () {
console.log("Save user Data 1 :"+this.up('window'));
//this.up('window').saveUserData();
this.saveUserData(); // this is not working
}
} ]
});
dialog.show();
},
saveUserData : function() {
alert("Save user Data");
// create an AJAX request
}
});
答案 0 :(得分:0)
怎么样:
openDialog : function() {
var me = this;
var dialog = Ext.create('Ext.window.Window', {
title : 'Permission Uesr',
itemId : 'adduserpopup',
id : 'adduserpopup',
closeAction: 'hide',
modal : true,
width : 1000,
height : 400,
layout : {
type: 'vbox',
align: 'stretch',
padding: 5
},
resizable : false,
items : [ createuserinformation,itemselectorGrid],
buttons : [ {
text : 'Save',
id : 'okbutton',
handler: function () {
console.log("Save user Data 1 :"+this.up('window'));
me.saveUserData(); // instead using this use local variable me
}
} ]
});
dialog.show();
},