PDA

View Full Version : view without controller



bennyl
27 Dec 2011, 12:04 AM
hi all,
i am new to extjs and wanted to start a simple demo project
in that project i have a simple layout : some header with logo and on the center some components
so i tried to create new header component that looks like that:



Ext.define('Proj.main.Header', {
extend: 'Ext.container.Container',
alias : 'widget.main-header',
items: [
{
xtype: 'image',
height: 80,
width: 200,
src: '/public/images/logo.png',
flex: 1
}
],


initComponent: function() {
var me = this;
me.callParent(arguments);
}
});


then i wanted to add it to the viewport like that :



Ext.application({
name: 'Proj',
appFolder: '/public/app',
//The main function
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'border',
items: [
{xtype: 'main-header', region: 'north', height: '100'}
]
});
}
});


but when i tried to do so i got error "Cannot call method 'substring' of undefined"
i concluded that this is happening because the view is not required anywhere so i added in the viewport definition :
requires: ['Proj.main.Header'] and when that not worked i added it to the require block before the application:

Ext.require('Ext.container.Viewport', 'Proj.main.Header');
that change the error to:
Uncaught TypeError: Object Proj.main.header has no method 'call'

what am i missing?

thanks, Benny.

skirtle
27 Dec 2011, 4:06 AM
In that last error I notice that the class name has a lower case h on header. I don't see why that would be from the code you've posted. I'd focus on that if I were you. If you can't see an obvious place that would occur then trying digging into the stacktrace a little (this may prove to be a nightmare for an error like this but give it a shot).

Do you see all the required files load in the Net/Network tab in whichever debugger you're using?

bennyl
27 Dec 2011, 3:12 PM
skirtle,
thanks for your answer, i fixed the lowered case 'h' but that didn't fix the error :(

i tried following the stack trace as you suggested and it lead me into the 'class' loading mechanism of extjs
lots of scary code... :)
also i checked and the view file didnt requested from the server at all...

i tried a different approach - i created an empty controller and called it Static
then in that controller i defined all the "static" views that i have - that fixed the problem

do you think i should submit a bug or that this is an intended behavior?

skirtle
27 Dec 2011, 3:41 PM
i fixed the lowered case 'h' but that didn't fix the error

What does the new error message say after you fixed the lower case letter issue? I'm keen to know where this issue occurred because it wasn't in any of the code you've posted on here, it implies there's other code you've got that might contain the root cause of your problem.


i tried following the stack trace as you suggested and it lead me into the 'class' loading mechanism of extjs
lots of scary code... :)

Yup.


also i checked and the view file didnt requested from the server at all...

Well that helps point the finger...


Ext.require('Ext.container.Viewport', 'Proj.main.Header');

should be:


Ext.require(['Ext.container.Viewport', 'Proj.main.Header']);


do you think i should submit a bug or that this is an intended behavior?

No, what you're seeing is almost certainly a result of bugs in your code.