PDA

View Full Version : Update Manager



jay@moduscreate.com
9 Mar 2007, 9:25 AM
How do i get a the response text for a .on("update", myfunc)?



var mgr = new Ext.UpdateManager('tach_num');
mgr.startAutoRefresh(10, "/tec_tach.php?last_time=" + last_time);
mgr.on("update", updateDiv);

function updateDiv (e) {
alert(e);
}



i'm seeing "[object Object]"

The doc says:
# callback : Function
(optional) Callback when transaction is complete - called with signature (oElement, bSuccess, oResponse)

How do i get at the responseText? I'm used to the old way "xmlhttp.responseText".

Thanks.

I've tried e.oResponse and no success.

Animal
9 Mar 2007, 9:47 AM
What are you wanting to do?

jay@moduscreate.com
9 Mar 2007, 9:48 AM
How do i get a the response text for a .on("update", myfunc)?
...
How do i get at the responseText? I'm used to the old way "xmlhttp.responseText".

i want to eval the response txt but i can't figure out how to use ext to do this. I'm probably going to fall back to just using plain o'l yui or just bare js.

jay@moduscreate.com
9 Mar 2007, 9:53 AM
is it as basic as:


27 var callback =
28 {
29 success:handleSuccess,
30 failure: handleFailure
31 argument: { foo:"foo", bar:"bar" }
32 };

?? :cry:

tryanDLS
9 Mar 2007, 9:53 AM
You only declared 1 arg in your call function. 'e' is the element. The response is the 3rd arg

jay@moduscreate.com
9 Mar 2007, 9:57 AM
_3 = undef

the target div gets updated.



var callback = function (_1, _2, _3) {
alert(_3);
}

tryanDLS
9 Mar 2007, 10:12 AM
How is your callback fn defined? Did you try this? Use the debug version or add updatemanager.js to your page and set a bp in processSuccess/processFailure to see what's happeing



function updateDiv(el, success, response) {
var r = response.responseText;
}

jay@moduscreate.com
9 Mar 2007, 10:25 AM
the 3rd parm of the callback is null/undef.

Found the following in the source:


updateComplete : function(_1d) {
this.fireEvent("update",this.el,_1d);
if ( typeof _1d.argument.callback=="function" ) {
_1d.argument.callback(this.el,true,_1d);
}}

I inserted an alert(_1d) in there and i got "object object". yet the callback's third parm is undef.

here is my code:


Ext.onReady(function(){
var dt = new Date();
var last_time = parseInt(dt.getTime()/1000) - 500 ;

var mgr = new Ext.UpdateManager('tach_num');
mgr.startAutoRefresh(10, "/tec_tach.php?last_time=" + last_time);
mgr.on("update", callback);

});


var callback = function (el, success, response) {
alert(response);
}


The third parm in the callback is still undef.
i'm just going to fall back to using plain yui.

Their examples work like a charm.

This has been a pretty frustrating 2hrs for me.

Thanks for your time guys. sorry for wasting it.

Animal
10 Mar 2007, 5:20 AM
dj, read the docs, and take a peek at the kindly provided, beautifully presented source code.

A callback is different from an update event handler. The callback is passed those three params. The update event handler is not. As documented. The callback is called whether the update failed or succeeded, so the indicator (param 2) is passed. The update event fires after a successful update.

Try:



var updateHandler = function (el, response) {
alert(response);
}