GithubHelp home page GithubHelp logo

Comments (6)

sagalbot avatar sagalbot commented on August 24, 2024

Could you post a gist of your complete component?

On a side note, It sounds like you could probably skip the filterGame remapping, and instead set a custom label:

<v-select label="name" :value.sync="form.primary_game" :options="games"></v-select>

This well tell vue-select to use game.name when creating labels.

from vue-select.

kylekz avatar kylekz commented on August 24, 2024

https://gist.github.com/xKairu/40be84413dad74c7173b4e95011f9dc7

I'm using Laravel Spark, if anything is confusing.

In regards to the label, what about the value? My data is stored as id/name rather than value/label, so is there an option to pick which key the plugin uses as the value too?

from vue-select.

sagalbot avatar sagalbot commented on August 24, 2024

Sorry for the delayed reply. Vue-select will simply return the entire object, no need to set a key.

I'm not sure what new SparkForm() returns, so I can't be of much help. If add a test property to your data object and set <v-select :value.sync="test">, does the value sync properly?

from vue-select.

kylekz avatar kylekz commented on August 24, 2024

SparkForm is essentially a wrapper around vue-resource that handles processing, validation errors etc.

If I just add a test variable into my data object then swap the value binding, the test variable is then updated when I select an option from the selectbox.

If I then add this.test = this.findGame(this.user.primary_game); into my getGames success callback, I get the same issue as before. It acts like a one way binding and not a two way. It's this part that fails.

Everything works fine, including the picking of the game within the selectbox and having the server update the user model, except taking the ID from the user model, pulling the full object from the games array and setting the default selected item.

from vue-select.

kylekz avatar kylekz commented on August 24, 2024

I've been trying to sort this out for two weeks now with no result. I've found that adding a click handler to some element and having it manually update the value works, as well as setting a timeout before setting the value, so I'm thinking the issue has something to do with the order of instantiation.

However I've just now fixed it by using vm.$nextTick like so:

this.$http.get('/api/game')
                .then(response => {
                    this.games = response.data.data;

                    this.$nextTick(() => {
                        this.form.primary_game = this.findGame(this.user.primary_game);
                    });
                });

from vue-select.

ebaguma avatar ebaguma commented on August 24, 2024

@kylewardnz please help me out, am having the same issue. Two way binding is not working, kindly clarify how you got it to work

from vue-select.

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.