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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page