Attach your event listener to your form instead of the seperate
elements, though I think it would be better if you didn't replace any
elements and just return a a better response from the server (for
example JSON with some vars/messages).

Reattaching event listeners is a pain and because you don't really
remove the old event listener it stays in the memory and thus creating
a memory leak.

Greetz,

Wizz

On Apr 29, 8:33 am, Oscar <[EMAIL PROTECTED]> wrote:
> Hi
>
> I´m having trouble while using Element.replace to handle changes made
> to an input element. Here´s what i´m doing:
>
> I´m using $(' element').onblur = function() {  } on a form to validate
> the field when the user tabs out or clicks on the next field, the
> validation is made on the php side and returns the code of the same
> input field plus some classes and a message of wheter the validation
> was ok or not. It looks something like this
>
> $('element').onblur = function() {
>
> pars = 'action=validate';
> new Ajax.Request('file.php', { parameters: pars, method: 'post',
> onComplete: function(newcode) {
>
>         $('element').replace(newcode.responseText);
>
> } });
> }
>
> This works fine the first time. But when i put the focus back into the
> field and the out again it does nothing. Looks like the problem is
> that when the element gets replaced even by one with the same name,
> id, etc. prototype doesn´t recognize it anymore and doesn´t execute
> the onBlur function.
>
> Is there a way around this or another approach i could take? I know i
> could do the changes using setStyle, etc. but i have a php session
> instance of a class where i store all the properties so i can access
> them on other pages, because of this i want php to handle the
> proccessing and use prototype just to apply the changes.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to