Aug 22, 2009, 10:27 PM
Problem with AjaxMethod and prototype
Hi,
Just wanted to know if there was a workaround for the following problem. I have created a javascript class using prototype. This class handles the clicking of a treepanel to create new tabs into a tab panel. The reason for the prototype class is just to tidy everything up as my tabpanel and treeview are in different usercontrols.
Anyhow the problem I have is that the prototype class is calling ajaxmethods from within it and I am using the { success : callback } feature. This does work but I think it is losing the scope as it makes the ajax call and returns. The callback fires but the prototype class has lots its settings eg. local values etc.
I can see what the problem is here. The ajax method is fired and on return it has lost a reference to the TreePanelManager class. Just wondering if someone could figure out how I could regain the scope back. I have figured out a workaround of doing away with all local references using (this.tree) but rather use the instance (tpm._tree) but this kind of breaks OO.
Below is some sample code of what I am doing .....
Just wanted to know if there was a workaround for the following problem. I have created a javascript class using prototype. This class handles the clicking of a treepanel to create new tabs into a tab panel. The reason for the prototype class is just to tidy everything up as my tabpanel and treeview are in different usercontrols.
Anyhow the problem I have is that the prototype class is calling ajaxmethods from within it and I am using the { success : callback } feature. This does work but I think it is losing the scope as it makes the ajax call and returns. The callback fires but the prototype class has lots its settings eg. local values etc.
I can see what the problem is here. The ajax method is fired and on return it has lost a reference to the TreePanelManager class. Just wondering if someone could figure out how I could regain the scope back. I have figured out a workaround of doing away with all local references using (this.tree) but rather use the instance (tpm._tree) but this kind of breaks OO.
Below is some sample code of what I am doing .....
vart tpm = new TreePanelManager('tree', 'tabPanel');
TreePanelManager = function(tree, tabPanel){
this._tree = tree;
this._tabPanel = tabPanel;
this._cbEditWindow = null;
this._cbEditWindowOwner = null;
this._tempAsyncNode = null;
}
TreePanelManager.prototype = {
doSometing : function (owner){
this._cbEditWindowOwner = owner;
this._cbEditWindow = new Ext.Window({
title: 'Edit content',
layout: 'fit',
modal: 'true',
width: 800,
height: 600,
autoLoad: { showMask: true, mode: 'iframe', url: url }
});
this._cbEditwindow.show();
Coolite.AjaxMethods.CreateNode({success: this.doResult});
},
doResult : function (result) {
// do something with result
// this._cbEditWindow always is null at this point
}