Hello,
On Oct 7, 1:20 pm, "1m.dm" <[email protected]> wrote:
> I just thought about Request.HTML update via diff, what means that
[...]
> Does it makes sense?
Kind of yes and kind of no.
The point of the out-of-band request technique in an AJAX response is
that you're not sending the whole document. Only the needed data is
sent and the page is re-rendered from there. To send a full HTML
document, or even very many portions you don't need, kind of defeats
the purpose. Just refresh the page... it will take about as much time
and is no challenge to code at all.
In the example you mention:
> would be very helpful, for example, with server-side form validation:
> after such update via diff element with validation errors would occur
> on a page, but you will not be required to re-assign any events you've
> might been assign to form elements, 'cause they aren't replaced!
Why not just adjust the properties of the fields in the form based on
a custom server response? Saves time and bandwidth, and no need for
re-assigning events.
Of course, if you need to replace the whole form for some reason (not
sure why this would be) you could have your initial form events set up
by a function like:
var setUpFormEvents = function(){
$('some-field').addEvents({[...]});
$('some-other-field').addEvents({[...]});
}
call it at domready:
document.addEvent('domready',setUpFormEvents);
and at the bottom of your request's onSuccess function
[...],
onSuccess: function (tree){
$('formContainer').empty();
$('formContainer').adopt(tree);
setUpFormEvents();
},
[...]