Giter Club home page Giter Club logo

Comments (16)

miguelcobain avatar miguelcobain commented on July 1, 2024

Currently not possible, but definitely doable!

from ember-cli-selectize.

topaxi avatar topaxi commented on July 1, 2024

I got the same problem from switching a plain select to selectize... :/

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 1, 2024

This is a top priority.

from ember-cli-selectize.

davekaro avatar davekaro commented on July 1, 2024

Maybe I'm not understanding, but this works for me saving the US State on an account object. state is just a string field on account. states is an array of strings:

{{ember-selectize
  content=states
  optionValuePath="content"
  optionLabelPath="content"
  selection=account.state
  placeholder="Select State" }}

from ember-cli-selectize.

topaxi avatar topaxi commented on July 1, 2024

Yes this works, but not if states is an array of objects of which you only want to select a property as value.
For example states is an array of objects with an property "name" which is a string. Then you wouldn't be able to bind the variable to the name, it would bind to the whole object.

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 1, 2024

@davekaro didn't occur to me passing just content to optionValuePath. Nice.

@topaxi, conceptually that makes sense to me.
A selection must be an element of content.

In the example you gave, what would be expected? To bind optionLabelPath to the selection? It's weird.

Could you post an example of Ember.Select that would do what you expect?
It would be easier for us to understand.

from ember-cli-selectize.

topaxi avatar topaxi commented on July 1, 2024

I'm using a bound query param to filter a result set. This means, the parameter is only the id, not an whole object.

{{view 'select'
  prompt = 'Filter customer'
  id = 'customer'
  class = 'form-control'
  content = customers
  value = customerId
  optionLabelPath = 'content.name'
  optionValuePath = 'content.id'
  }}

I expected that I could just swap view 'select' with ember-selectize but this didn't work out.
I guess the value path should bind to the selection (or value in case of single value selections?), like the Ember.Select view.
It was quite simple to switch out select views which selected whole objects though 👍

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 1, 2024

I think I nailed the problem.
After reading the docs it seems that Ember.Select provides both value and selection bindings.
selection will have the selected object. value will have the selected value.

We currently only support selection. So, I'm assuming that adding support for value would be enough to cover your use case, right?

from ember-cli-selectize.

topaxi avatar topaxi commented on July 1, 2024

Yes that would totally cover my case, not sure about @salzhrani though.

from ember-cli-selectize.

salzhrani avatar salzhrani commented on July 1, 2024

I agree

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 1, 2024

@topaxi Any idea on what happens to value when selection is multiple?

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 1, 2024

Quoting Ember Select source:

In single selection mode (when multiple is false), value can be used to
get the current selection's value or set the selection by it's value.
It is not currently supported in multiple selection mode.

from ember-cli-selectize.

topaxi avatar topaxi commented on July 1, 2024

It seems to be an array though: http://emberjs.jsbin.com/hovonohude/1/

from ember-cli-selectize.

topaxi avatar topaxi commented on July 1, 2024

But in any case, single value solves our issue and covers the official ember documentation so i guess it should be fine :)

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 1, 2024

Updated to 0.0.11.
This should be working for single values. Just bind value property.

Also, the default valuePath and labelPath are now content, so this:

{{ember-selectize
  content=states
  optionValuePath="content"
  optionLabelPath="content"
  selection=account.state
  placeholder="Select State" }}

becomes this

{{ember-selectize
  content=states
  selection=account.state
  placeholder="Select State" }}

@topaxi
On a side note, I looked through Ember Select source code and couldn't find how that JSBin happens. o.O

from ember-cli-selectize.

topaxi avatar topaxi commented on July 1, 2024

very nice thanks a lot! :)

from ember-cli-selectize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.