PDA

View Full Version : UpdateManager + defaults


Choleriker
02-11-2007, 03:31 AM
Hey,

i short hint: i have seen that the version 1.0 of yui-ext has a nice extension to preset the default for all update-managers like this:


Ext.UpdateManager.defaults.disableCaching = true;
Ext.UpdateManager.defaults.loadScripts = true;
Ext.UpdateManager.defaults.showLoadIndicator = true;
Ext.UpdateManager.defaults.indicatorText = '<div class="loading-indicator">'+Texts.Loading+'</div>'


COOL! Set it once and never set this before update. But one i miss: call a method by default after updating. I need this, because my data-requests dont returns only data, it can contain actions, maybe 'alert' and so on and i want automatically to parse this actions after an update.

The solution: simply create a function-sequence on the prototype for the update() method to prebound the update-event.


Ext.UpdateManager.prototype.update = Ext.UpdateManager.prototype.update.createSequence(function() {
if(typeof this.updatePreset=='undefined') {
this.updatePreset = true;
this.on('update', function(el, o) {
// maybe check the content-type to ensure only use json/javascript content in the form-handler

// get the data and pass it to the form-handler
this.data = eval('('+o.responseText+')');
Lm.Forms.handleResponse(this.data);
}, this, true);
}
});


YUI-EXT rockz!

jack.slocum
02-14-2007, 05:01 PM
Ah, someone finally found out about createSequence! I love that function (and interceptor) as it can be used to create a completely custom event that was never defined easily.:)

mdissel
02-15-2007, 04:56 AM
Thanks for this tip!!

I had the same request (AjaxPro returns result.value / result.error)..

Thanks

Marco

Animal
02-15-2007, 05:05 AM
What about using a custom renderer? You have total control of what's done with the response that way.

Choleriker
02-18-2007, 05:54 PM
What about using a custom renderer? You have total control of what's done with the response that way.

Thats a cool idea. Its more simple. Thank you!

Jack: i have used this createSequence to get easy access to the asp.net forms predefined events. The coolest thing: i can now get Infos about the validate events of asp.net without changing the internally functionallity of asp.net.

mdissel
02-20-2007, 02:39 PM
Jack: i have used this createSequence to get easy access to the asp.net forms predefined events. The coolest thing: i can now get Infos about the validate events of asp.net without changing the internally functionallity of asp.net.

Can you share some examples??

Thanks

Marco

Choleriker
02-25-2007, 09:02 AM
Can you share some examples??


Hey Marco! Asp.net renders validation functions and form submit functions depending on what controls you are using on your site and depending if they are using maybe validation. __doPostBack() maybe is used on every server-roundtrip because the asp.net stateless page-model uses hidden fields to get previous states back to the server. This is really good documented, look on msdn-library or ask google for it.

All you need to catch the built-in asp.net functions is to use yui-ext createSequence to get your function before the asp.net one. With this way you can easily do what you want with this ones. But there is another nice way to do that, you can implement this on server-side! There are many many articles at the web how to do anything like this.

If you dont find anything informations, let me know. In my oppinion the best way to handle asp.net client stuff is to implement it on server side, its faster for the client!