PDA

View Full Version : [Solved] Prototype.js vs YUI? Ajax.Updater Equivalent.



cluettr
28 Jun 2007, 11:22 AM
I have for the last 2 years or so used prototype.js as my framework. I've run into some issues here with the prototype adapter and I'm willing to try the YUI framework for my calls. The only problem is I am not sure how I would generate a YUI function to be the equivalent of the Ajax.Updater function of prototype.js where the div or span is automatically populated with the response.

My thinking is to pass the response to a success callback function and set the inner div. Does this sound accurate? Will this process any <script></script> tags that are part of the response similar to setting evalScripts to true in prototype.js?

I guess realistically I could create a wrapper function that accepts the same variables in the same structure as a typical Ajax.Updater and not have to change all that much...

Your input would be appreciated. Thank you.

tryanDLS
28 Jun 2007, 2:49 PM
With 1.1beta1, you can use the ext-base adapter, rather than YUI. You can continue to include your prototype includes (minus the adapter) to facilitate any existing prototype based code. As for updating elements, look at the UpdateManager class, the Element.load fn (which shortcuts the UpdateManager process) - there are config options to process scripts in the content you load. There are numerous threads and examples of using these items which should get you started

cluettr
28 Jun 2007, 4:11 PM
Thank you. The below is the code before (prototype way) and after (Extjs way)... the before is commented out:



function changeMenuRight(option)
{
// fetch('contents_selector_right_' + option + '.php','','selector_menu_right_contents','post')
// var randomnumber = Math.floor(Math.random()*100001);
// var myAjax = new Ajax.Updater('selector_menu_right_contents','contents_selector_right_' + option + '.php?rand=' + randomnumber,{method: 'get',asynchronous: true,evalScripts: true});

var um = Ext.get('selector_menu_right_contents').getUpdateManager();
um.loadScripts=true;
um.update('contents_selector_right_' + option + '.php');

}