PDA

View Full Version : BasicDialog with one TabPanelItem a try to submit form



JuanParraC
1 Dec 2006, 4:15 PM
Hi Jack, great work...
I'm new to the yui and yui-ext extension.
and I have a questions ...
In BasicDialog with one TabPanelItem a try to submit a simple form..
The server response a simple text, with this text i want to replace the TabPanelItem

Thanks

....
my code:

String.prototype.htmlDecode = function(){
var ret;
var sReplace = /\+/gi;

ret= unescape(this);
ret = ret.replace(sReplace, " ");
return(ret);
}


var fncSubmitFrm = function() {

var fncSuccess = function(o){
[list:3610349b2e]var data = o.responseText.htmlDecode();

// UPDATE dialog-tabItemPanel
// it works! but it is the way to do this?
var tabEls = YAHOO.util.Dom.getElementsByClassName('ydlg-tab', 'div', dialog.el.dom);
getEl(tabEls[0].id).update(data,true);
var Tab = dialog.getTabs().getTab(tabEls[0].id);

// get new content
tabEls = YAHOO.util.Dom.getElementsByClassName('ydlg-tab', 'div', dialog.el.dom);
// why tabEls[1] ?????
Tab.setText(tabEls[1].title);
tabEls[1].title='';


};

var fncFailure = function(o){
alert(o.responseText);
};

YAHOO.util.Connect.setForm(document.getElementById('form1'));
var frmAction = document.getElementById('form1').action;
YAHOO.util.Connect.asyncRequest('POST',frmAction,{success: fncSuccess , failure: fncFailure }); [/list:u:3610349b2e]
};


dialog = new YAHOO.ext.BasicDialog('ID',
{
modal:true,
autoTabs:true,
width:280,
height:180,
shadow:true,
minWidth:300,
minHeight:200,
closable:true
}
);

dialog.addButton('Submit', fncSubmitFrm );

Animal
1 Dec 2006, 11:56 PM
Don't use DOM calls. Use the methods of TabPanel (getTab) to get the TabPanelItem you want. Get its UpdateManager, and call formUpdate on that.

http://www.yui-ext.com/deploy/yui-ext/docs/

JuanParraC
3 Dec 2006, 11:30 AM
Thanks Animal,
but the server responds with Response.Write (Server.URLEncode (shtml))
for that reason I had to implement the function
String.prototype.htmlDecode = function(){var ret;
var sReplace = /\+/gi;
ret= unescape(this);
ret = ret.replace(sReplace, " ");
return(ret);}
How to use formUpdate in this case?

Animal
3 Dec 2006, 1:42 PM
You mean that the server sends back non-standard HTML, or some kind of response that needs "massaging" to produce valid HTML?

Then add a custom renderer to the TabPanelItem's UpdateManager: http://www.yui-ext.com/deploy/yui-ext/docs/output/YAHOO.ext.UpdateManager.html#setRenderer

JuanParraC
3 Dec 2006, 9:12 PM
yes, I try to do this. now i have to another problem, with this way the form values are not passed :(

Animal
4 Dec 2006, 12:15 AM
http://www.yui-ext.com/deploy/yui-ext/docs/output/YAHOO.ext.UpdateManager.html#formUpdate

It POSTS the form with all form inputs sent.

You can add your own extra params in the url parameter - which can be a function which returns a URL, so you can code this to know all about your object and set up appropriatye params.