Fix et2_checkbox_ro widget for exceptional cases when we pass value as Non-Boolean

This commit is contained in:
Hadi Nategh 2013-10-05 14:04:10 +00:00
parent 43e1bfcc12
commit 54ab073cab

View File

@ -20,9 +20,9 @@
/**
* Class which implements the "checkbox" XET-Tag
*
*
* @augments et2_inputWidget
*/
*/
var et2_checkbox = et2_inputWidget.extend(
{
attributes: {
@ -60,7 +60,7 @@ var et2_checkbox = et2_inputWidget.extend(
/**
* Constructor
*
*
* @memberOf et2_checkbox
*/
init: function() {
@ -95,7 +95,7 @@ var et2_checkbox = et2_inputWidget.extend(
*/
set_value: function(_value) {
if(_value != this.value) {
if(_value == this.options.selected_value ||
if(_value == this.options.selected_value ||
_value && this.options.selected_value == this.__proto__.attributes.selected_value["default"] &&
_value != this.options.unselected_value) {
this.input.prop("checked", true);
@ -135,7 +135,7 @@ var et2_checkbox_ro = et2_checkbox.extend(
/**
* Constructor
*
*
* @memberOf et2_checkbox_ro
*/
init: function() {
@ -147,9 +147,14 @@ var et2_checkbox_ro = et2_checkbox.extend(
this.setDOMNode(this.span[0]);
},
/**
* note: checkbox is checked if even there is a value but not only if the _value is only "true"
* it's an exceptional validation for cases that we pass non boolean values as checkbox _value
*/
set_value: function(_value) {
if(_value == this.options.selected_value) {
if(_value == this.options.selected_value ||_value && this.options.selected_value == this.__proto__.attributes.selected_value["default"] &&
_value != this.options.unselected_value) {
this.span.text(this.options.ro_true);
this.value = _value;
} else {