fixed radiobutton not (always) returning correct value plus fixing ide warnings

This commit is contained in:
Ralf Becker 2014-02-13 09:50:49 +00:00
parent e84d243b5d
commit 8d86f8496b

View File

@ -103,6 +103,8 @@ var et2_radiobox = et2_inputWidget.extend(
/**
* Override default to match against set/unset value AND iterate over all siblings with same id
*
* @param {string} _value
*/
set_value: function(_value)
{
@ -116,13 +118,22 @@ var et2_radiobox = et2_inputWidget.extend(
},
/**
* Override default to return unchecked value
* Override default to iterate over all siblings with same id
*
* @return {string}
*/
getValue: function() {
if(jQuery("input:checked", this._parent.getDOMNode()).val() == this.options.set_value) {
return this.options.set_value;
}
return null;
getValue: function()
{
var val = this.options.value; // initial value, when form is loaded
this.getRoot().iterateOver(function(radio)
{
if (radio.id == this.id && radio.input && radio.input.prop('checked'))
{
val = radio.options.set_value;
}
}, this, et2_radiobox);
return val;
}
});
et2_register_widget(et2_radiobox, ["radio"]);
@ -175,6 +186,8 @@ var et2_radiobox_ro = et2_valueWidget.extend([et2_IDetachedDOM],
/**
* Override default to match against set/unset value
*
* @param {string} _value
*/
set_value: function(_value) {
if(_value == this.options.set_value) {
@ -186,6 +199,8 @@ var et2_radiobox_ro = et2_valueWidget.extend([et2_IDetachedDOM],
/**
* Code for implementing et2_IDetachedDOM
*
* @param {array} _attrs
*/
getDetachedAttributes: function(_attrs)
{
@ -296,7 +311,8 @@ var et2_radioGroup = et2_valueWidget.extend([et2_IDetachedDOM],
/**
* Set a bunch of radio buttons
* Options should be {value: label, ...}
*
* @param {object} _options object with value: label pairs
*/
set_options: function(_options) {
for(var key in _options)
@ -322,6 +338,8 @@ var et2_radioGroup = et2_valueWidget.extend([et2_IDetachedDOM],
/**
* Set a label on the group of radio buttons
*
* @param {string} _value
*/
set_label: function(_value) {
// Abort if ther was no change in the label
@ -335,7 +353,7 @@ var et2_radioGroup = et2_valueWidget.extend([et2_IDetachedDOM],
// Create the label container if it didn't exist yet
if (this._labelContainer == null)
{
this._labelContainer = $j(document.createElement("label"))
this._labelContainer = $j(document.createElement("label"));
this.getSurroundings().insertDOMNode(this._labelContainer[0]);
}
@ -365,6 +383,8 @@ var et2_radioGroup = et2_valueWidget.extend([et2_IDetachedDOM],
* Code for implementing et2_IDetachedDOM
* This doesn't need to be implemented.
* Individual widgets are detected and handled by the grid, but the interface is needed for this to happen
*
* @param {object} _attrs
*/
getDetachedAttributes: function(_attrs)
{