Code Monkey home page Code Monkey logo

Comments (3)

rmagnum2002 avatar rmagnum2002 commented on June 4, 2024

I should've read the closed issues first, my bad.. #28

from vue-select2.

rmagnum2002 avatar rmagnum2002 commented on June 4, 2024

Back with some more details.. because for some reason it doesn't work for me. After reading the issue tagged above, I switched from options to v-model

<Select2 @select="selectEvent($event, selectedValues.catToolsOptions)"
         v-model="catTools"
         :settings="{ multiple: true }"
         :disabled='showReviewTab' />

vue data

data: function () {
  return {
    catTools: []
  }
}

in mounted callback I am calling a method, that calls an API to get data for select

loadCatToolsOptions () {
  let url = '/api/translators/cat_tools.json'

  this.axios.get(url).then(response => {
    # this is an action in vuex, to loop through all available options and mark the ones selected based on options from other component
    this.setCatToolsOptions(response.data)
    # assigning the data from store to this component model
    this.catTools = this.catToolsOptions
  })
},

In the end, my model has the following data

[{"id":1,"text":"TRADOS","selected":true},{"id":2,text":"ACROSS","selected":true},{"id":3,"text":"WORDFAST","selected":false},{"id":4,"text":"MemoQ","selected":false},{"id":5,"text":"Transit","selected":false},{"id":6,"text":"InDesign","selected":true},{"id":7,"text":"Omega","selected":false},{"id":8,"text":"SDLX","selected":false},{"id":9,"text":"Memsource","selected":false}]

which look like valid data for select2 component. But still, there are no preselected options. Even hardcoding the above Array of objects to catTools data model is not working. What am I doing wrong?

from vue-select2.

rmagnum2002 avatar rmagnum2002 commented on June 4, 2024

Ok.. for others who get into the same thing :)
v-model should hold the id's of preselected options, in my case catTools should have [1, 2, 6].
while options still holds the information about available options.

from vue-select2.

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.