PDA

View Full Version : Ext.widget with modern widgets



adjioev
16 Jul 2015, 4:51 PM
Hello,

I'm trying to implement login part for my universal application, bellow is my launch function from Application.js:


launch: function () {
var loggedIn;
loggedIn = localStorage.getItem("StormUserDetails");
Ext.widget(loggedIn ? 'app-main' : 'login');
},

That works but I found that Ext.widget() doesn't load widget instance in modern view.

If I try to load those widgets via mainView in app.js everything works perfectly.

Thanks Alex

mitchellsimoens
17 Jul 2015, 5:48 AM
You need to require classes properly anyway so when you run a build it will require those classes. So you need to add the two components that have the xtype 'app-main' and 'login' into the requires array in your application.

adjioev
19 Jul 2015, 11:41 PM
Hi Mitchell, yep, I've done that, still blank screen. What I found is that my classic Main.js has plugins: 'viewport' line. There is no viewport plugin in modern API, so is there a way to convert modern Main.js that extends Ext.tab.Panel into Viewport? Thanks alex

mitchellsimoens
20 Jul 2015, 4:01 AM
This simple fiddle works:

qp0

adjioev
20 Jul 2015, 3:19 PM
Hi Mitchel,

you are using mainView param and that works for me too. I was trying to follow this exercise https://docs.sencha.com/extjs/5.1/tutorials/login_app.html and make it work in modern API. So I need something like this withoout MainView Ext.widget() isntead:



Ext.define('Fiddle.view.Main', {
extend : 'Ext.tab.Panel',
xtype : 'fiddle-main',

items : [
{
title : 'Foo',
html : 'foo'
},
{
title : 'Bar',
html : 'bar'
}
]
});

Ext.application({
name : 'Fiddle',

//mainView : 'Fiddle.view.Main',
launch: function() {
Ext.widget('fiddle-main');
}
});

Thanks alex

wolfganga
26 Aug 2015, 7:37 AM
Make sure to add the container to the viewport when using launch(). Using the config, Ext does this automagically for you.




// inside launch()
var mainView = Ext.create('App.view.main.Main');
if (Ext.Viewport.add) {
Ext.Viewport.add(mainView);
}



Also: If this is based on the classic toolkit, make sure that the container uses plugin "viewport". This is not needed when using modern though.

Regards

Wolfgang

mounir1
20 May 2018, 10:08 PM
Make sure to add the container to the viewport when using launch(). Using the config, Ext does this automagically for you.




// inside launch()
var mainView = Ext.create('App.view.main.Main');
if (Ext.Viewport.add) {
Ext.Viewport.add(mainView);
}



Also: If this is based on the classic toolkit, make sure that the container uses plugin "viewport". This is not needed when using modern though.

Regards

Wolfgang

I's been a while,but I am wondering if there is an else for that statement so the modern can excute the widget different way !!