PDA

View Full Version : autoLoad panel problems with update....



CaptainKeebler
30 Sep 2010, 9:07 AM
Here's my class



Ext.ns('My.NS.FairlyComplexWindow');
My.NS.FairlyComplexWindow = Ext.extend(Ext.Window, (function() {

var comboBox = new Ext.form.ComboBox({configStuff});

var myBustedPanel = new Ext.Panel({
region: 'north',
id: 'myBustedPanelId',
border: false,
height: 50,
autoLoad: {
url: 'url/to/html/content.html',
scripts: true,
callback: function() {
comboBox.render($('aDivIdFromLoadedHTML'));
}
}
});

return {
constructor: function(config){
config = config || {};
My.NS.FairlyComplexWindow.superclass.constructor.apply(this, arguments);
},

initComponent: function(){
var config ={ conf:stuff, conf2:moreStuff };
Ext.apply(this, config);
Ext.apply(this.initialConfig, config);
//more code
My.NS.FairlyComplexWindow.superclass.initComponent.apply(this, arguments);
},

/* ... more functions here... */

showMe: function(){
//init some other things, then show me
this.show();
}
}//end return
}())
);
Ext.reg('fairlycomplexwindow', My.NS.FairlyComplexWindow);

Here's the problem.

The myBustedPanel panel will only load HTML from the provided URL in the autoLoad configs once, when we new up a FairlyComplexWindow(). FairlyComplexWindow is really a modal edit dialog. The first time the window is shown, everything works just fine. Then I close the window, try to open the window again, the comboBox will not render.

I need to reload that HTML in myBustedPanel in the FairlyComplexWindow.show() function. If I dont, when I go to render comboBox I get an error because that div doesn't exist anymore.

I've tried the following methods to reload the html



showMe: function(){
var el = Ext.get('myBustedPanelId');
var mgr = el.getUpdater();
mgr.update({url: 'url/to/html/content.html'});
this.show();
}
here el is null, myBustedPanelId doesn't exist in the dom.

so next:



showMe: function(){

myBustedPanel.load({
url: 'url/to/html/content.html',
scripts: true,
callback: function() {
comboBox.render($('aDivIdFromLoadedHTML'));
}
});
this.show();
}
Here we have another problem:

this.body is undefined
/scripts/ext-3.2.1/ext-all-debug.js
Line 15881

In Ext.Panel, this.body is always null.



load : function(){ var um = this.body.getUpdater();
um.update.apply(um, arguments);
return this;
},
I've moved the declaration of myBustedPanel into the initComponent() method with no luck. I could use some help here.. what am I doing wrong?

troseberry
30 Sep 2010, 9:32 AM
does


closeAction: 'hide' work anybetter if you add it to your window config?

CaptainKeebler
30 Sep 2010, 9:56 AM
I have a closeDialog() method, I should have included it here. I am using this.hide() to close FairlyComplexWindow, but I have a couple of other things to clean up before I can just close it.

CaptainKeebler
1 Oct 2010, 6:17 AM
bump, any ideas?

CaptainKeebler
14 Oct 2010, 3:59 PM
The real problem here is using autoload in any component that extends any other ext component. I guess dumping html into an ext panel just hoses everything up. I've compared the generated HTML from the first time the dialog renders and the second time the dialog renders.

the first time everything displays and functions properly, the second time the combo box doesnt display and the generated html is way larger and has a TON of junk in it and odd css all over. I don't know whats going on here. also if you use autoload on a panel, it's element will not exist, nor will it's updater. odd stuff.

and it's not just combo boxes, it can be any random component in a panel that uses autoLoad.

Is there any documentation around autoLoad? Any best practices around autoLoad (besides i know now to NOT use it)? I'm getting tired of stepping through core Ext code to try and figure out what it *really* does.. the docs sure don't tell you much...

Animal
14 Oct 2010, 9:28 PM
I don't understand why you would want to load HTML.

Why don't you use Ext?

CaptainKeebler
15 Oct 2010, 6:23 AM
I don't understand why you would want to load HTML.

Why don't you use Ext?


it's not my call :(

winklerd
15 Oct 2010, 10:19 AM
If you just need to reload the content specified in the autoLoad, try this.getUpdater().refresh();

CaptainKeebler
15 Oct 2010, 10:21 AM
getUpdater() is undefined. Ext.getCmp('myBustedPanelId') is also undefined.

winklerd
15 Oct 2010, 10:26 AM
The updater will not be available until after the panel renders (which is also when the body gets defined and the content in the autoLoad is loaded). Try adding anything that references the updater into an afterrender listener.

CaptainKeebler
15 Oct 2010, 10:33 AM
i will look into that as well. render is only ever called once, the first time the panel is rendered. if i close the window and try to open it again, rendered = true and render() is never called, so i don't think afterrender will fire? i dunno. I will give it a shot, thanks for the idea.

cap'n

winklerd
15 Oct 2010, 10:36 AM
Alternatively, you can also try putting this.show() above the updater statements which will help ensure that the panel shows (and therefore we know it has rendered) before trying to update.