[Proto-Scripty] Re: Does $A('.classname').invoke('setValue',...) work on checkboxes?

2009-11-12 Thread Szymon Wilkołazki

joe t. wrote:
 i agree on that. setValue has its purpose pretty much in the name.
 Set the value of a control. For checkboxes, setChecked
 (bool) (also applying to radios?) would have made a lot more sense.
 

Yes, it does apply to radios to. It's a shame that the docs aren't 
clear on this behavior.

You can play a little with this test page:
http://tsalarioth.art.pl/~sw/setValueTest.html

I personally think it would be better if setValue on radio and 
checkbox either really set the value, or set the checked state base on 
comparison:

Element.setValue = function(element, newValue) {
 $(element).checked = ($(element).value == newValue);
}

This way, you could check or uncheck the element, especially radio, 
based on that if value is matching. This would be useful for methods 
similar to Form.unserialize();

It is of course impossible to be done at this state of the library, 
where the code is used in (hundreds of) thousands of scripts among the 
web.

I will probably write additional method for my needs with use of the 
excellent Element.extend method.

Anyway,
I want to thank all the prototype.js developers, doc writers and 
supporters for your work on the library. Great job!

Best regards,
SWilk

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Does $A('.classname').invoke('setValue',...) work on checkboxes?

2009-11-11 Thread joe t.

i agree on that. setValue has its purpose pretty much in the name.
Set the value of a control. For checkboxes, setChecked
(bool) (also applying to radios?) would have made a lot more sense.

i suppose in the meantime there's Element.writeAttribute
({value:foo});

However, i raise caution on that because i've had inconsistent results
in the past where the DOM recognizes the attribute as changed, but the
browser did not update the visual display of the value (text inputs at
the time), and submitted the original value. It was as though the
input tag's value attribute and the control's value property were
different entities. The only way i found to address it was $
('element').value = foo; which obviously kills the elegance of
chaining methods, but seems to address both entities, and is how
Form.Element.Serializers returns other values.

-joe t.


On Nov 10, 12:30 pm, Szymon Wilkołazki wilkola...@gmail.com wrote:
 Hi,

 I found where is the problem.

 I assumed, that the Form.Element.setValue method sets the value of an
 element.

 In case of checkboxes that is not true.
 The method changes the state of checked/unchecked instead, and leaves
 the value attribute unchanged.

 The example might be found here:

 http://tsalarioth.art.pl/~sw/setValueTest.html

 As you can see, if you click on the button set value of checkbox to:
  with empty input, the checkbox is unchecked. If the value is not
 empty, then checkbox will be checked.

 I do not understand why this behaviour was chosen, but I understand
 that it can't be changed now, as it would break backward compatibility.

 Anyway I think the setValue method needs better documentation, as it
 is now a  little bit misleading.

 I will open a lighthouse DOC ticket for this.

 Best regards,
 SWilk
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Does $A('.classname').invoke('setValue',...) work on checkboxes?

2009-11-10 Thread Szymon Wilkołazki

Hi,

I found where is the problem.

I assumed, that the Form.Element.setValue method sets the value of an 
element.

In case of checkboxes that is not true.
The method changes the state of checked/unchecked instead, and leaves 
the value attribute unchanged.

The example might be found here:

http://tsalarioth.art.pl/~sw/setValueTest.html

As you can see, if you click on the button set value of checkbox to: 
 with empty input, the checkbox is unchecked. If the value is not 
empty, then checkbox will be checked.

I do not understand why this behaviour was chosen, but I understand 
that it can't be changed now, as it would break backward compatibility.

Anyway I think the setValue method needs better documentation, as it 
is now a  little bit misleading.

I will open a lighthouse DOC ticket for this.

Best regards,
SWilk






--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---