Reputation: 15928
I am trying to get this to work in sencha fiddle. If I run it I see this error in the console log "Uncaught TypeError: controller.setView is not a function". It works only if I remove the controller declaration from the view. What am i doing wrong?
Ext.define('MyApp.controller.Whatever', {
extend: 'Ext.app.Controller',
alias: 'controller.Whatever',
init: function() {
alert("Yes!");
}
});
Ext.define('MyApp.view.Whatever', {
extend: 'Ext.form.Panel',
controller: 'Whatever',
title: 'Hello',
width: 200,
html: '<p>World!</p>',
renderTo: Ext.getBody()
});
Ext.application({
name: 'MyApp',
launch: function() {
Ext.create('MyApp.view.Whatever');
}
});
Based on the answer below this worked
Ext.define('MyApp.controller.Whatever', {
extend: 'Ext.app.ViewController',
alias: 'controller.Whatever',
init: function() {
alert("Yes!");
}
});
Ext.define('MyApp.view.Whatever', {
extend: 'Ext.form.Panel',
alias:'widget.Whatever',
controller: 'Whatever',
title: 'Hello',
width: 200,
html: '<p>World!</p>',
renderTo: Ext.getBody()
});
Ext.application({
name: 'MyApp',
launch: function() {
Ext.create('MyApp.view.Whatever');
}
});
Upvotes: 2
Views: 3117
Reputation: 1449
I think you are using Ext JS 5 or above version so use this.
Ext.app.ViewController instead of Ext.app.Controller.
Upvotes: 9