|
229 | 229 | var $select = $editor.find('select'); |
230 | 230 | var update = function() |
231 | 231 | { |
232 | | - $enable.attr('checked', property.value !== false); |
233 | | - $select.attr('disabled', property.value === false); |
| 232 | + var value = (property.value == null) ? false : property.value; |
| 233 | + $enable.attr('checked', value); |
| 234 | + $select.attr('disabled', value); |
234 | 235 | updateOptions(); |
235 | 236 | }; |
236 | 237 |
|
237 | 238 | var updateOptions = function() |
238 | 239 | { |
239 | 240 | var $options = $select.find('option').detach(); |
240 | | - var selectedValue = property.value[0]; // default to the saved value. |
| 241 | + var selectedValue = (property.value == null) ? undefined : property.value[0]; // default to the saved value. |
241 | 242 |
|
242 | 243 | _.each(optionsProperty.value, function(option) |
243 | 244 | { |
|
246 | 247 | selectedValue = option.val; |
247 | 248 |
|
248 | 249 | // on the other hand, if we have no ref yet and we match, grab the ref. |
249 | | - if ((selectedOption == null) && (property.value[0] === option.val)) |
| 250 | + if ((selectedOption == null) && (selectedValue === option.val)) |
250 | 251 | selectedOption = option; |
251 | 252 |
|
252 | 253 | var existing = _.find($options, function(dom) { return $(dom).data('option') === option; }); |
253 | 254 | existing = (existing == null) ? $('<option/>').data('option', option) : $(existing); |
254 | 255 | $select.append(existing.text(option.val).attr('value', option.val)); |
255 | 256 | }); |
256 | 257 |
|
257 | | - if (property.value !== false) |
| 258 | + if ((property.value !== false) && (property.value != null)) |
258 | 259 | { |
259 | 260 | if (selectedValue != null) |
260 | 261 | { |
|
0 commit comments