Problem that I have always had with the Form.Observer is that it
doesn't return the form element which was updated, just the actual
form. Not that useful. While back I got the code below from someone (I
think on this Google Group) which will return the element, however it
doesn't work on forms with radio buttons, and will instead start an
infinite loop of returning events.

How do you deal with getting the element on a form observer? Do you
have a better solution? Thanks.

Form.Observer = Class.create(Abstract.TimedObserver, {
        getValue: function() {
                return Form.serialize(this.element, true);
        }
        , execute: function() {
                var value = this.getValue();
                for (var prop in value) {
                        if (value[prop] != this.lastValue[prop]) {
                                this.callback(this.element, 
Object.toQueryString(value),
this.element.down('[name="'+ prop +'"]'));
                                this.lastValue = value;
                                break;
                        }
                }
        }
});
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to