View Full Version : UpdateManager not firing "update" event

12 Mar 2007, 1:49 PM
I am having trouble with the UpdateManager.on("update", function....) method (including the script eval) - it doesn't seem to fire. In the below code, I am able to log the "beofreupdate" event, but nothing is logged for the "update" event AND the scripts in the returned HTML are not eval'd. I have traced the code, and it seems like it's not getting to the section where it runs event handlers, but I don't know why. Here's the code:

var orderSubLayout = new Ext.BorderLayout(tempDIV, {autoCreate: true,
center: {
autoScroll: true,
titlebar: false,
north: {
initialSize: 30,
collapsible: true,
animate: false,
autoScroll: false,
titlebar: false

var orderTab = new Ext.ContentPanel("orderContent"+orderID, {autoCreate: true});

var orderTabButtons = new Ext.ContentPanel("orderButtons"+orderID, {autoCreate: true, closable: false});

orderTabButtons.getUpdateManager().on("beforeupdate", function (object){console.log('beforeupdate');}, this, true);
orderTabButtons.getUpdateManager().on("update", function (object){console.log('update');}, this, true);

orderSubLayout.add('center', orderTab);
orderSubLayout.add('north', orderTabButtons);

var returnData = MasterLayout.layout.add('center', new Ext.NestedLayoutPanel(orderSubLayout, {id: "order"+orderID, title: 'Order #'+orderID, closable: true}));

12 Mar 2007, 2:53 PM
Try setting a BP in UpdateManager processSuccess and processFailure. It's possible that the eval of your script is failing. You could also add a handler for the 'failure' event and see if you get there. There are several other threads about loading scripts - problems can be caused by comments for example.

18 Mar 2007, 7:04 PM
I have narrowed the issue. It appears when the "loadScripts" is set to TRUE, the code takes a new path (shown with line numbers from ext-all-debug.js):

4771 if(this.loadScripts){
4772 this.renderer.render(this.el, response, this,
4773 this.updateComplete.createDelegate(this, [response]));
4774 }else{
4775 this.renderer.render(this.el, response, this);
4776 this.updateComplete(response);
4777 }

When this occurs, I am unable to readably trace the call into the prototype adapter, as it's minified, but it appears that the delegate function does not fire (aka, this.updateComplete()). I am assuming it's waiting to fire after the scripts have all been eval'd, but there are no scripts in this test case I am running right now, just plain HTML (though I am working up to having scripts in the loaded HTML, I am not there yet).

Can anyone shed some light on the createDelegate(...) method? It would seem that this could be a bug affecting the prototype-based usage only, and only when loadScripts is turned on.

19 Mar 2007, 12:22 AM
If you keep doing "step into" through the delegate method, you'll eventually end up in the code that's specified to be called, so you can get there.

See the Wiki for info on the Ext Function methods. They are very useful.


19 Mar 2007, 9:04 AM
I think the issue is with variable scoping in the onAvailable method in ext-prototype-adapter.js. I added some logging to it, and it seems that no matter what it keeps looking for the same element (even though it should be looking for a new element). I modified it slightly and it works. New code here (this includes my added logging) - it looks like the bug was a var name collision on "el"....

onAvailable : function(eli,fn,_35,_36){
var _37=new Date(),iid;
var f=function(){
console.log('giving up on element: '+eli);
var el=$(eli);
console.log('found element: '+eli);

I also had to modify the code being called to find script blocks (Added a STRING cast), around line 3040 of ext-all-debug modified as follows:

var srcMatch = String(match[1]).match(srcRe);

With these changes in place, the code works, and evals scripts in loaded content as expected.