PDA

View Full Version : New to extjs, MVC tutorial onPanelRendered not called



jonjanisch
12 Mar 2012, 10:32 AM
Hi, I'm new to ExtJS and JS in general. I'm just getting started with the basic MVC tutorial and I'm having issues: http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture

I'm using ext-4.1.0-beta-3.



Ext.require('Ext.container.Viewport');


Ext.application({
name: 'HelloExt',
controllers: [
'Users'
],
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{
xtype: 'panel',
title: 'Hello Ext',
html : 'Hello! Welcome to Ext JS.'
}
]
});
}
});


* The getting started guide said I should see a warning in the console and I should add the Ext.require line to prevent this. I never saw any error regardless if this line is included or excluded in either Chrome's console or firebug.

That's not a problem though. My Users controller looks like this:



Ext.define('HelloExt.controller.Users', {
extend: 'Ext.app.Controller',

init: function() {
this.control({
'viewport > panel': {
render: this.onPanelRendered
}
});
console.log('Users controller initialized');
},

onPanelRendered: function() {
console.log("The panel was rendered");
}
});


'Users controller initialized' is outputted to the console, but it seems onPanelRendered is never getting executed. Actually, being new to JS I'm not even sure how to debug this. In firebug, I put a breakpoint in the control method, but the breakpoints appear to be removed as soon as I refresh the page.

The only change I made from the Getting Started 'Hello World' tutorial was adding xtype: 'panel' to app.js to match the account manager app in the MVC tutorial. Am I missing something? I don't see any errors or warnings in the firebug or chrome console.

Thanks

mitchellsimoens
12 Mar 2012, 10:57 AM
beta 3 had a bug where the render and afterrender events wouldn't make it to the controller. This has been fixed for the next release.

jonjanisch
12 Mar 2012, 11:02 AM
Thanks. That was my first guess, but I figured if it was in the Hello World example, I must be doing something wrong.