PDA

View Full Version : HELP ! app is undefined, app is application name



ouewqa
21 Oct 2011, 1:25 AM
Ext.application({
name: 'app',
launch: function(){
console.log(app);
}
});


console: app is undefined

SunboX
21 Oct 2011, 1:58 AM
You have to add a Controller!



Ext.Loader.setConfig({ enabled: true });

Ext.application({
name: 'App',

// the controller will take care of creating the view
controllers: ['AppController'],

launch: function() {
console.log('app launch');
console.log(App);
}
});


greetings Sunny

jep
22 Oct 2011, 9:37 PM
I think part of the confusion is that the docs haven't yet been updated for that.

jep
22 Oct 2011, 9:40 PM
Also, when I run your code with 2.0 pr 1, I get:

Uncaught Error: [Ext.Loader] Failed loading 'app/controller/AppController.js', please verify that the file exists

So no idea how this is all supposed to work.

SunboX
23 Oct 2011, 1:26 AM
HereĀ“s a simple "Helleo World" example:

https://github.com/FrancisShanahan/SenchaTouch2MVCHelloworld

greetings Sunny

jep
23 Oct 2011, 11:25 AM
That's one of the most complicated "Hello World" examples I've ever seen. ;)

I really hope this isn't what is expected of a "simple" Sencha app. If so, this is a big departure from previous versions. I think the whole MVC thing is overkill in many applications.

FYI, here's how I would work around the app variable not being defined in the original example:



Ext.application({
name: 'app',
launch: function(){
app = this;
console.log(app);
}
});

SunboX
23 Oct 2011, 12:02 PM
In my opinion it's easy. Even small Apps will benefit from this MVC architecture. You can't get an app without a bit of work and learning. ;o)

greetings Sunny

jep
23 Oct 2011, 12:04 PM
I think you've entirely missed the point of a "hello, world" app. If this is the "simple" way to learn ST, it's use will become much more limited and it will wither on the vine.

Luckily, I don't believe that is the case. MVC is simply not always appropriate. If it was, nobody would ever create stuff that wasn't MVC.

SunboX
23 Oct 2011, 12:14 PM
Yes, there are non MVC Apps inside the example folder of the ST2-PR1 download. But if you get it working, you should think of MVC. It's difficult at the beginning but will get easier the more complex your app get's.

Greetings Sunny

jep
23 Oct 2011, 12:15 PM
The problem isn't that there are no non-MVC examples. The problem is, as stated in the original post, Ext.application seems to not be filling in the "name" field with the object instance as it did prior to 2.0. I think this is probably an oversight (at least in non-MVC apps).

SunboX
23 Oct 2011, 12:26 PM
Jep, maybe it should posted as a bug report.

arislaw
23 Oct 2011, 1:09 PM
I am spending one week to do what I usually do in one day... and I still cannot get a DataView working...

MVC is very nice and I like it very much, but it looks very complicated comparing with others MVC frameworks...