PDA

View Full Version : YAHOO.util.Connect questions.....



genius551v
21 Nov 2006, 10:13 AM
Hi,

I have this:



function loadNodeData(node, fnLoadComplete) {
// get data for MenuTree
alert(node);
var nodo_name = node.data.label;
alert(nodo_name);
var cb = {success: handleSuccess, failure: handleFailure}

YAHOO.util.Connect.asyncRequest('POST','domain/getDataMenuTree.php',cb,'nodo_name='+nodo_name);

(*)

}

this function is for load nodos dynamic to menu tree from my server, thats ok but...

the loop for add nodos is :



//dummy data for myfolders parent
var oCarData = {
COLECCIONES: ["9-2", "9-3", "9-5", "Aero", "Viggen"] <- this must be o.responseText
};

var children = oCarData[node.data.label];

//loop through children array
for (var i=0; i<children.length; i++) {
thisModel = children[i];
var newNode = new YAHOO.widget.TextNode({label:thisModel}, node, false);
//by the clicked label
newNode.onLabelClick = onLabelClick;
}
fnLoadComplete();


se supone q este loop debe estar DENTRO de la funcion right here ->(*), but cuando se ejecuta la function loadNodeData and the YAHOO.util.Connect.asyncRequest response cb==SUCCESS la ejecucion se va para -> success: handleSuccess

COMO HAGO PARA Q SE QUEDE DENTRO DE loadNodeData Y PODER SEGUIR EJECUTANDO LA FUNCTION loadNodeData

NOTE: I NEED handleSuccess = function(o){...
o.responseText <-- MY NODE DATA!!
...}

cualquier ayuda les agradesco mil y mil gracias!

Tnks

tryanDLS
21 Nov 2006, 10:49 AM
no habla espanol, :) but are you asking why it doesn't invoke your handleSucess method?

If so, you probably want to add a 'scope' property to your callback object e.g
var cb = {scope:this, success: handleSuccess, failure: handleFailure}

YAHOO will look for the scope property and try to call your handleSuccess method in that scope.

If you set a BP in the YUI Connect.handleTransactionResponse method, you'll see how it looks at your callback object and determines how to route the request.