iStefo / ember-select-2

DEPRECATED IN FAVOR OF https://github.com/cibernox/ember-power-select
MIT License
144 stars 119 forks source link

Check if dropdown is selected from the promised value when the binding value property is a promise #30

Closed Jcarlosjunior closed 9 years ago

Jcarlosjunior commented 9 years ago

{{select-2 value=myValue content=myContent optionLabelPath='name' allowClear=true}}

If "myValue" in the example above is a "belongsTo" in ember-data, even when it doenst have a content it's value is not null or any falsy value, because the property it's a promise that resolves to its promised (real) value. I think if the ember-select-2 could see if the property is a promise and check if there is a promised value to set the dropdown as selected or not.

Jcarlosjunior commented 9 years ago

The binding is working wonderfully for promised properties, the only thing is that a binding to a promise property that doensnt have a promisedValue (is null and/or not even set) is treating like it is a selection from the dropdown, because the placeholder don't show up and the "x" (from the allowClear option) is visible.

iStefo commented 9 years ago

This fix will be included in the next release, I will reference this issue in the roadmap issue :)

jpaas commented 9 years ago

I swear this used to work for me but has recently regressed. Perhaps because I've been upleveling ember and ember data?

I have a select for a hasOne relationship called 'resource' that looks like this:

          {{select-2
          optionLabelPath='name'
          placeholder=(format-message (intl-get 'attributes.resource-node.resource'))
          query='queryResources'
          value=model.resource
          }}

My select renders fine if model.resource is null, but if it has a value, the select doesn't render even after the promise has been resolved.

I'm using: