PDA

View Full Version : Getting component reference within a non-Ext JS 4 Javascript psuedo-class



mbritton
18 Jan 2012, 1:50 PM
The Ext JS 4 library is present in my includes. This file is my application, where I'm going to put all my Ext stuff:



Ext.define('view.extjs.ExtView', {
extend:'Ext.app.Application',
alias:'widget.extview',
launch: function() {
console.log('ExtView Launch');
}
});


In another, non-Ext Javascript class, I want to get a reference to this application and add items to it. I'm not using Viewport.

How is this done? This isn't working:

Ext.create('view.extjs.ExtView', {
launch: function() {
console.log('ExtView Launch');
}
});


Thanks in advance!

lorezyra
18 Jan 2012, 4:13 PM
Why would you want to reference an ExtJS component/object from a "non-Ext" class?

Why not build the functionality you need inside the Ext.application() call?

What is your use-case?

lorezyra
18 Jan 2012, 4:17 PM
If you need easy access to the application object, then try this code:



Ext.Application({
name:"myApp",
//controllers: [],
//stores: [],
launch: function () {
//your code here...

App = new App();
App.setApp(this);
}
});

mbritton
19 Jan 2012, 8:08 AM
I'm a bit of a n00b, so I apologize. This is research for a browser-based application that may require multiple client-tier technologies, based on their strengths and the availability of certain third-party components.

That said, how would I get a reference to the application from a non-Ext Javascript psuedo class?