[object Object] as option value


#1

Hi all, I notice that one of the option in our ember app has all the values set to [object Object]. This is sort of ok from the functional point of view because they do have a unique id. However it prevents some testing tool to select properly as they work with the value rather than the id. Has somebody experience this issue? Any ideas? Thanks Damian


#2

Sounds like it’s trying to render an object as a string. What code are you using to generate the select (this is for a select right?) and what does your data look like?


#3

Yes, it looks like it. Here is the template: {{#if hasBlock}} {{yield}} {{else}} {{#if placeholder}} {{placeholder}} {{/if}} {{#each _optionValues key="@index" as |option|}} {{#x-option value=option.value}}{{option.label}}{{/x-option}} {{/each}} {{/if}}

and the js code

/* globals */

import Ember from ‘ember’; import XSelect from ‘emberx-select-blockless/components/x-select-blockless’; var PhmsSelect = XSelect.extend({ _updateValueSingle: function(){ var option = this.get(‘options’).find(function(option) { return option.().is(':selected'); }); if (option) { this.set('value', option.get('value')); } else { if(this.().siblings(’.chosen-container’).length > 0){ var value = this.$().siblings(’.chosen-container’).find(“span”).html(); if(!Ember.isEmpty(value)){ this.set(‘value’, value); }else{ this.set(‘value’, undefined); } }else{ this.set(‘value’, undefined); }

}

},

});

export default PhmsSelect;