Hi everybody!
First of all, prototype is a great library.
But I have a problem with getting the last changed value in
Form.Observer. Have already asked that question in Prototype: Core
mailing list, but nobody asked me yet. So sorry for duplicating it
here also.
For example, if I''ll do:
new Form.Observer($(form), 0.2, some_callback_function);
function some_callback_function() {
console.log(this.getValue());
console.log(this.lastValue());
}
It will log two different strings. But how to get diff between those
two values?
I need that, because I have much of elements in form, and I need to
get name of the element, that have just changed. Form.Element.Observer
isn''t suit to solve my problem, because I have set of radio buttons
(first argument of Form.Element.Observer is ID of input element).
In previous example, I can search for string, like:
---
Radio buttons name: hinge_id, form: step3
Helper:
function $RC(form, name) {
return $(form).getInputs(''radio'',
name).find(function(radio) {
if (radio.checked) {
return radio;
}
});
}
In callback:
var hinge_id = $RC(''step3'', ''hinge_id'');
if (hinge_id != null) {
var hinge_id_regexp = new RegExp(''hinge_id=([0-9]+)'');
hinge_id_before = this.lastValue.match(hinge_id_regexp);
hinge_id_now = this.getValue().match(hinge_id_regexp);
if (hinge_id_before != null && hinge_id_before[1]
!hinge_id_now[1])
{
console.log(hinge_id_before + '':'' +
hinge_id_now);
}
}
---
but is it a good practice, or?
Thank you for your help,
Dmitry
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---