diff --git a/public/javascripts/control.js b/public/javascripts/control.js index 0ae9747c..1ec67ee8 100644 --- a/public/javascripts/control.js +++ b/public/javascripts/control.js @@ -110,7 +110,7 @@ _.each(properties, function(property) { if (property.bindControlClass != null) - $this.toggleClass(property.bindControlClass, property.value !== false); + $this.toggleClass(property.bindControlClass, ((property.value != null) && (property.value !== false))); }); // SPECIAL CASE: diff --git a/public/javascripts/property-editor.js b/public/javascripts/property-editor.js index 1eec8866..e32eb7b0 100644 --- a/public/javascripts/property-editor.js +++ b/public/javascripts/property-editor.js @@ -229,15 +229,16 @@ var $select = $editor.find('select'); var update = function() { - $enable.attr('checked', property.value !== false); - $select.attr('disabled', property.value === false); + var value = (property.value == null) ? false : property.value; + $enable.attr('checked', value); + $select.attr('disabled', value); updateOptions(); }; var updateOptions = function() { var $options = $select.find('option').detach(); - var selectedValue = property.value[0]; // default to the saved value. + var selectedValue = (property.value == null) ? undefined : property.value[0]; // default to the saved value. _.each(optionsProperty.value, function(option) { @@ -246,7 +247,7 @@ selectedValue = option.val; // on the other hand, if we have no ref yet and we match, grab the ref. - if ((selectedOption == null) && (property.value[0] === option.val)) + if ((selectedOption == null) && (selectedValue === option.val)) selectedOption = option; var existing = _.find($options, function(dom) { return $(dom).data('option') === option; }); @@ -254,7 +255,7 @@ $select.append(existing.text(option.val).attr('value', option.val)); }); - if (property.value !== false) + if ((property.value !== false) && (property.value != null)) { if (selectedValue != null) {