How to get an object in v-model? VuetifyTrouble with Vue.js v-model within Quasar q-select tag dynamically rendering computed propertiesVuetify Select Component Initial Value issueHow to bind v-model to v-selectvue.js wrapping components which have v-modelsv-select (vuetify) cant show the seleted elementVuetify: v-model looks deprecatedVuetify - how to easily access v-select item-text value?Vuetify timepicker return value to modelVuetify v-select value not returning keyHow to get append-outer-icon working in vuetify?

Can you identify this lizard-like creature I observed in the UK?

Difference between shutdown options

Ways of geometrical multiplication

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

How do I fix the group tension caused by my character stealing and possibly killing without provocation?

Given this phrasing in the lease, when should I pay my rent?

What is this high flying aircraft over Pennsylvania?

Why do Radio Buttons not fill the entire outer circle?

Pre-Employment Background Check With Consent For Future Checks

How do I Interface a PS/2 Keyboard without Modern Techniques?

Why didn't Voldemort know what Grindelwald looked like?

The Digit Triangles

Does Doodling or Improvising on the Piano Have Any Benefits?

How to get directions in deep space?

Do I have to take mana from my deck or hand when tapping a dual land?

Limit max CPU usage SQL SERVER with WSRM

Echo with obfuscation

Sound waves in different octaves

How to make a list of partial sums using forEach

Language involving irrational number is not a CFL

What should be the ideal length of sentences in a blog post for ease of reading?

Anime with legendary swords made from talismans and a man who could change them with a shattered body

Why does the Persian emissary display a string of crowned skulls?

Mimic lecturing on blackboard, facing audience



How to get an object in v-model? Vuetify


Trouble with Vue.js v-model within Quasar q-select tag dynamically rendering computed propertiesVuetify Select Component Initial Value issueHow to bind v-model to v-selectvue.js wrapping components which have v-modelsv-select (vuetify) cant show the seleted elementVuetify: v-model looks deprecatedVuetify - how to easily access v-select item-text value?Vuetify timepicker return value to modelVuetify v-select value not returning keyHow to get append-outer-icon working in vuetify?













1















I am using v-autocomplete to get user's input in a form.



<v-autocomplete
v-model="selected"
:items="items"
item-text="short"
item-value="long"
chips
deletable-chips/>


The structure of items is like this:



[

"long": "item-key",
"property": [

"long": "I dont need this",
"short": "this is what I need"

],
"short": "item-text"
]


and I need to access the property field of what user has selected when the key should be long. So I was wondering if there is a way that v-model holds the whole object so that I can access the property in other parts of the form? If not then what is an alternative way I could use to solve the problem?



I greatly appreciate any help










share|improve this question



















  • 1





    You can use <v-autocomplete return-object ... and remove item-value="long" From the docs,

    – ljubadr
    Mar 7 at 22:13












  • Thank you @ljubadr. I use it like this <div v-for="item in selected.property" >item.short </div> but there is a problem and that is when I deselect the item that was selected I would still see item.short on the DOM unless I refresh. Should not that be gone since it is in the v-model?

    – DjSh
    Mar 10 at 20:19






  • 1





    When you clear selection, this.selected will be null, and your v-for="item in selected.property" will throw error. You need to wrap that in <template v-if="selected"> <div v-for="....">... </div></template>

    – ljubadr
    Mar 10 at 21:28











  • You should probably create computed property: getSelectedPropertyShort() return this.selected ? this.selected.property[0].short : ''. Not sure which values you will have in your property array, but this only works if long/short are first values in the array. And if you have more complex logic, it's easy to add it in this computed property

    – ljubadr
    Mar 10 at 21:36











  • @ljubadr v-if worked. Do I still need the computed property?

    – DjSh
    Mar 10 at 21:42















1















I am using v-autocomplete to get user's input in a form.



<v-autocomplete
v-model="selected"
:items="items"
item-text="short"
item-value="long"
chips
deletable-chips/>


The structure of items is like this:



[

"long": "item-key",
"property": [

"long": "I dont need this",
"short": "this is what I need"

],
"short": "item-text"
]


and I need to access the property field of what user has selected when the key should be long. So I was wondering if there is a way that v-model holds the whole object so that I can access the property in other parts of the form? If not then what is an alternative way I could use to solve the problem?



I greatly appreciate any help










share|improve this question



















  • 1





    You can use <v-autocomplete return-object ... and remove item-value="long" From the docs,

    – ljubadr
    Mar 7 at 22:13












  • Thank you @ljubadr. I use it like this <div v-for="item in selected.property" >item.short </div> but there is a problem and that is when I deselect the item that was selected I would still see item.short on the DOM unless I refresh. Should not that be gone since it is in the v-model?

    – DjSh
    Mar 10 at 20:19






  • 1





    When you clear selection, this.selected will be null, and your v-for="item in selected.property" will throw error. You need to wrap that in <template v-if="selected"> <div v-for="....">... </div></template>

    – ljubadr
    Mar 10 at 21:28











  • You should probably create computed property: getSelectedPropertyShort() return this.selected ? this.selected.property[0].short : ''. Not sure which values you will have in your property array, but this only works if long/short are first values in the array. And if you have more complex logic, it's easy to add it in this computed property

    – ljubadr
    Mar 10 at 21:36











  • @ljubadr v-if worked. Do I still need the computed property?

    – DjSh
    Mar 10 at 21:42













1












1








1








I am using v-autocomplete to get user's input in a form.



<v-autocomplete
v-model="selected"
:items="items"
item-text="short"
item-value="long"
chips
deletable-chips/>


The structure of items is like this:



[

"long": "item-key",
"property": [

"long": "I dont need this",
"short": "this is what I need"

],
"short": "item-text"
]


and I need to access the property field of what user has selected when the key should be long. So I was wondering if there is a way that v-model holds the whole object so that I can access the property in other parts of the form? If not then what is an alternative way I could use to solve the problem?



I greatly appreciate any help










share|improve this question
















I am using v-autocomplete to get user's input in a form.



<v-autocomplete
v-model="selected"
:items="items"
item-text="short"
item-value="long"
chips
deletable-chips/>


The structure of items is like this:



[

"long": "item-key",
"property": [

"long": "I dont need this",
"short": "this is what I need"

],
"short": "item-text"
]


and I need to access the property field of what user has selected when the key should be long. So I was wondering if there is a way that v-model holds the whole object so that I can access the property in other parts of the form? If not then what is an alternative way I could use to solve the problem?



I greatly appreciate any help







vue.js customization vuetify.js v-model v-select






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 10 at 20:41







DjSh

















asked Mar 7 at 21:58









DjShDjSh

7812




7812







  • 1





    You can use <v-autocomplete return-object ... and remove item-value="long" From the docs,

    – ljubadr
    Mar 7 at 22:13












  • Thank you @ljubadr. I use it like this <div v-for="item in selected.property" >item.short </div> but there is a problem and that is when I deselect the item that was selected I would still see item.short on the DOM unless I refresh. Should not that be gone since it is in the v-model?

    – DjSh
    Mar 10 at 20:19






  • 1





    When you clear selection, this.selected will be null, and your v-for="item in selected.property" will throw error. You need to wrap that in <template v-if="selected"> <div v-for="....">... </div></template>

    – ljubadr
    Mar 10 at 21:28











  • You should probably create computed property: getSelectedPropertyShort() return this.selected ? this.selected.property[0].short : ''. Not sure which values you will have in your property array, but this only works if long/short are first values in the array. And if you have more complex logic, it's easy to add it in this computed property

    – ljubadr
    Mar 10 at 21:36











  • @ljubadr v-if worked. Do I still need the computed property?

    – DjSh
    Mar 10 at 21:42












  • 1





    You can use <v-autocomplete return-object ... and remove item-value="long" From the docs,

    – ljubadr
    Mar 7 at 22:13












  • Thank you @ljubadr. I use it like this <div v-for="item in selected.property" >item.short </div> but there is a problem and that is when I deselect the item that was selected I would still see item.short on the DOM unless I refresh. Should not that be gone since it is in the v-model?

    – DjSh
    Mar 10 at 20:19






  • 1





    When you clear selection, this.selected will be null, and your v-for="item in selected.property" will throw error. You need to wrap that in <template v-if="selected"> <div v-for="....">... </div></template>

    – ljubadr
    Mar 10 at 21:28











  • You should probably create computed property: getSelectedPropertyShort() return this.selected ? this.selected.property[0].short : ''. Not sure which values you will have in your property array, but this only works if long/short are first values in the array. And if you have more complex logic, it's easy to add it in this computed property

    – ljubadr
    Mar 10 at 21:36











  • @ljubadr v-if worked. Do I still need the computed property?

    – DjSh
    Mar 10 at 21:42







1




1





You can use <v-autocomplete return-object ... and remove item-value="long" From the docs,

– ljubadr
Mar 7 at 22:13






You can use <v-autocomplete return-object ... and remove item-value="long" From the docs,

– ljubadr
Mar 7 at 22:13














Thank you @ljubadr. I use it like this <div v-for="item in selected.property" >item.short </div> but there is a problem and that is when I deselect the item that was selected I would still see item.short on the DOM unless I refresh. Should not that be gone since it is in the v-model?

– DjSh
Mar 10 at 20:19





Thank you @ljubadr. I use it like this <div v-for="item in selected.property" >item.short </div> but there is a problem and that is when I deselect the item that was selected I would still see item.short on the DOM unless I refresh. Should not that be gone since it is in the v-model?

– DjSh
Mar 10 at 20:19




1




1





When you clear selection, this.selected will be null, and your v-for="item in selected.property" will throw error. You need to wrap that in <template v-if="selected"> <div v-for="....">... </div></template>

– ljubadr
Mar 10 at 21:28





When you clear selection, this.selected will be null, and your v-for="item in selected.property" will throw error. You need to wrap that in <template v-if="selected"> <div v-for="....">... </div></template>

– ljubadr
Mar 10 at 21:28













You should probably create computed property: getSelectedPropertyShort() return this.selected ? this.selected.property[0].short : ''. Not sure which values you will have in your property array, but this only works if long/short are first values in the array. And if you have more complex logic, it's easy to add it in this computed property

– ljubadr
Mar 10 at 21:36





You should probably create computed property: getSelectedPropertyShort() return this.selected ? this.selected.property[0].short : ''. Not sure which values you will have in your property array, but this only works if long/short are first values in the array. And if you have more complex logic, it's easy to add it in this computed property

– ljubadr
Mar 10 at 21:36













@ljubadr v-if worked. Do I still need the computed property?

– DjSh
Mar 10 at 21:42





@ljubadr v-if worked. Do I still need the computed property?

– DjSh
Mar 10 at 21:42












1 Answer
1






active

oldest

votes


















0














No, that would go against the core concept of Vue its self.



Instead, let's use a getter:



get selectedItemObject() 
return this.items.filter(obj => obj.property[0].long === this.selected)



Psueo code here, make sure to make it type and selector safe.






share|improve this answer























  • Thank you very much for your help. I have never seen using a getter before in Vue. Where would I put it? in methods or computed property?

    – DjSh
    Mar 10 at 19:35












  • I might have not been very clear on my question but I dont need the property[0].long and the items array could be very long. This is just the structure. Sorry for any confusion on my part. I have updated my question to show which one is the key

    – DjSh
    Mar 10 at 20:45










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053457%2fhow-to-get-an-object-in-v-model-vuetify%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














No, that would go against the core concept of Vue its self.



Instead, let's use a getter:



get selectedItemObject() 
return this.items.filter(obj => obj.property[0].long === this.selected)



Psueo code here, make sure to make it type and selector safe.






share|improve this answer























  • Thank you very much for your help. I have never seen using a getter before in Vue. Where would I put it? in methods or computed property?

    – DjSh
    Mar 10 at 19:35












  • I might have not been very clear on my question but I dont need the property[0].long and the items array could be very long. This is just the structure. Sorry for any confusion on my part. I have updated my question to show which one is the key

    – DjSh
    Mar 10 at 20:45















0














No, that would go against the core concept of Vue its self.



Instead, let's use a getter:



get selectedItemObject() 
return this.items.filter(obj => obj.property[0].long === this.selected)



Psueo code here, make sure to make it type and selector safe.






share|improve this answer























  • Thank you very much for your help. I have never seen using a getter before in Vue. Where would I put it? in methods or computed property?

    – DjSh
    Mar 10 at 19:35












  • I might have not been very clear on my question but I dont need the property[0].long and the items array could be very long. This is just the structure. Sorry for any confusion on my part. I have updated my question to show which one is the key

    – DjSh
    Mar 10 at 20:45













0












0








0







No, that would go against the core concept of Vue its self.



Instead, let's use a getter:



get selectedItemObject() 
return this.items.filter(obj => obj.property[0].long === this.selected)



Psueo code here, make sure to make it type and selector safe.






share|improve this answer













No, that would go against the core concept of Vue its self.



Instead, let's use a getter:



get selectedItemObject() 
return this.items.filter(obj => obj.property[0].long === this.selected)



Psueo code here, make sure to make it type and selector safe.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 22:09









OhgodwhyOhgodwhy

35.1k63969




35.1k63969












  • Thank you very much for your help. I have never seen using a getter before in Vue. Where would I put it? in methods or computed property?

    – DjSh
    Mar 10 at 19:35












  • I might have not been very clear on my question but I dont need the property[0].long and the items array could be very long. This is just the structure. Sorry for any confusion on my part. I have updated my question to show which one is the key

    – DjSh
    Mar 10 at 20:45

















  • Thank you very much for your help. I have never seen using a getter before in Vue. Where would I put it? in methods or computed property?

    – DjSh
    Mar 10 at 19:35












  • I might have not been very clear on my question but I dont need the property[0].long and the items array could be very long. This is just the structure. Sorry for any confusion on my part. I have updated my question to show which one is the key

    – DjSh
    Mar 10 at 20:45
















Thank you very much for your help. I have never seen using a getter before in Vue. Where would I put it? in methods or computed property?

– DjSh
Mar 10 at 19:35






Thank you very much for your help. I have never seen using a getter before in Vue. Where would I put it? in methods or computed property?

– DjSh
Mar 10 at 19:35














I might have not been very clear on my question but I dont need the property[0].long and the items array could be very long. This is just the structure. Sorry for any confusion on my part. I have updated my question to show which one is the key

– DjSh
Mar 10 at 20:45





I might have not been very clear on my question but I dont need the property[0].long and the items array could be very long. This is just the structure. Sorry for any confusion on my part. I have updated my question to show which one is the key

– DjSh
Mar 10 at 20:45



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053457%2fhow-to-get-an-object-in-v-model-vuetify%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme