Git Product home page Git Product logo

Comments (6)

alexeyolenikov avatar alexeyolenikov commented on July 22, 2024 1

@adamberecz hi, i have the same problem, when getting options asynchronously (render select with empty options and then update otions)

@v1r0x, hi! You can fix your problem by adding 'v-if=state.roles.length" to multiselect component

from multiselect.

adamberecz avatar adamberecz commented on July 22, 2024 1

Added a patch in 1.3.1 where nextTick is no longer required.

from multiselect.

adamberecz avatar adamberecz commented on July 22, 2024

You're welcome @v1r0x, I'm glad you like it! I've tried this based on what's available (without store) and the initial value was loaded correctly:

<template>
  <div>
    <multiselect
        v-model="value"
        :label="'display_name'"
        :track-by="'display_name'"
        :valueProp="'id'"
        :mode="'tags'"
        :searchable="true"
        :options="options"
        :placeholder="'Placeholder'">
    </multiselect>
  </div>
</template>

<script>
  import multiselect from '@vueform/multiselect'

  export default {
    components: {
      multiselect,
    },
    data() {
      return {
        value: [1],
        options: [
          { "id": 1, "name": "admin", "display_name": "Administrator", "description": "Project Administrator",
          "created_at": "2017-12-20T09:47:35.000000Z", "updated_at": "2017-12-20T09:47:35.000000Z" },
          { "id": 2, "name": "guest", "display_name": "Guest", "description": "Guest User",
          "created_at": "2017-12-20T09:47:35.000000Z", "updated_at": "2017-12-20T09:47:35.000000Z" }
        ]
      }
    }
  }
</script>

<style src="@vueform/multiselect/themes/default.css"></style>

So I assume the issue is in the environment, which I cannot see in your example. You should create a complete example that produces the error in JSFiddle so that I can look into further.

from multiselect.

v1r0x avatar v1r0x commented on July 22, 2024

@alexeyolenikov Hey there! I actually thought I already tried that. But I think I did not 🙈 I'll try it next week. Thanks for the hint!

Edit: It actually works with v-if="state.roles.length"! 🎉
If there's a way to show async options without v-if this would be awesome! \m/

from multiselect.

c4y avatar c4y commented on July 22, 2024

I tried to set options and v-model on mount (jsFiddle). It does not work. The options are set, but the value is not set. Is it a bug? Or how can i set options and value(s) at once after a api request?

from multiselect.

c4y avatar c4y commented on July 22, 2024

With $nextTick it works!! See jsFiddle

from multiselect.

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.