Vue-multiselect: Can I reference by Id the data , instead this - value: { name: 'Vue.js', language: 'JavaScript' } , just make like this - value: 2

Created on 19 Feb 2017  Â·  2Comments  Â·  Source: shentao/vue-multiselect

Hello my friend , To I select a data , I need to do it -

 data () {
    return {
      value: [
        { name: 'Vue.js', language: 'JavaScript' }
      ],
      options: [
        { name: 'Vue.js', language: 'JavaScript' },
        { name: 'Adonis', language: 'JavaScript' },
        { name: 'Rails', language: 'Ruby' },
        { name: 'Sinatra', language: 'Ruby' },
        { name: 'Laravel', language: 'PHP' },
        { name: 'Phoenix', language: 'Elixir' }
      ]
    }
  }

So this will be selected - { name: 'Vue.js', language: 'JavaScript' } , If I want to send this value to PHP , I need sed all this data - { name: 'Vue.js', language: 'JavaScript' } .
could I reference by ID instead ? just doing like this - value: 2 ? like this example -

 data () {
    return {
      value: [2 ],
      options: [
        { id:1', language: 'JavaScript' },
        { id: 2, language: 'JavaScript' },
        { id:3, language: 'Ruby' },
        { id:4, language: 'Ruby' },
        { id: 5, language: 'PHP' },
        { id: 6, language: 'Elixir' }
      ]
    }
  }

And send just the value ID , this one - value: [2 ] ? could I do it ? thanks

question

Most helpful comment

This would be super helpful, I have to do all sorts of transformations on my value to get it to send an object rather than the plugin just matching where object.value = value rather than object = object exactly.

All 2 comments

Not yet possible – you have to provide an object with at least the fields that are required to compare with other options (track-by prop) and the label prop.
This is due to being able to modify the options list dynamically, without breaking the currently selected options.

This would be super helpful, I have to do all sorts of transformations on my value to get it to send an object rather than the plugin just matching where object.value = value rather than object = object exactly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

volkanciloglu picture volkanciloglu  Â·  3Comments

wujekbogdan picture wujekbogdan  Â·  4Comments

stefanheimann picture stefanheimann  Â·  4Comments

wujekbogdan picture wujekbogdan  Â·  4Comments

Uninen picture Uninen  Â·  4Comments