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?
What exploit Are these user agents trying to use?
Why didn't Boeing produce its own regional jet?
In 'Revenger,' what does 'cove' come from?
What about the virus in 12 Monkeys?
Unlock My Phone! February 2018
Can the Meissner effect explain very large floating structures?
What is a romance in Latin?
Extract rows of a table, that include less than x NULLs
Is "remove commented out code" correct English?
Can my sorcerer use a spellbook only to collect spells and scribe scrolls, not cast?
Is it inappropriate for a student to attend their mentor's dissertation defense?
How can I deal with my CEO asking me to hire someone with a higher salary than me, a co-founder?
Why didn't Miles's spider sense work before?
What's the in-universe reasoning behind sorcerers needing material components?
Venezuelan girlfriend wants to travel the USA to be with me. What is the process?
How do conventional missiles fly?
Should I cover my bicycle overnight while bikepacking?
ssTTsSTtRrriinInnnnNNNIiinngg
What does the expression "A Mann!" means
Could the museum Saturn V's be refitted for one more flight?
Arrow those variables!
What reasons are there for a Capitalist to oppose a 100% inheritance tax?
Which is the best way to check return result?
How writing a dominant 7 sus4 chord in RNA ( Vsus7 chord in the 1st inversion)
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?
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
|
show 1 more comment
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
1
You can use<v-autocomplete return-object ...and removeitem-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 seeitem.shorton the DOM unless I refresh. Should not that be gone since it is in thev-model?
– DjSh
Mar 10 at 20:19
1
When you clear selection,this.selectedwill benull, and yourv-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 yourpropertyarray, 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
@ljubadrv-ifworked. Do I still need the computed property?
– DjSh
Mar 10 at 21:42
|
show 1 more comment
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
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
vue.js customization vuetify.js v-model v-select
edited Mar 10 at 20:41
DjSh
asked Mar 7 at 21:58
DjShDjSh
313215
313215
1
You can use<v-autocomplete return-object ...and removeitem-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 seeitem.shorton the DOM unless I refresh. Should not that be gone since it is in thev-model?
– DjSh
Mar 10 at 20:19
1
When you clear selection,this.selectedwill benull, and yourv-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 yourpropertyarray, 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
@ljubadrv-ifworked. Do I still need the computed property?
– DjSh
Mar 10 at 21:42
|
show 1 more comment
1
You can use<v-autocomplete return-object ...and removeitem-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 seeitem.shorton the DOM unless I refresh. Should not that be gone since it is in thev-model?
– DjSh
Mar 10 at 20:19
1
When you clear selection,this.selectedwill benull, and yourv-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 yourpropertyarray, 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
@ljubadrv-ifworked. 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
|
show 1 more comment
1 Answer
1
active
oldest
votes
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.
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 theproperty[0].longand 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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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 theproperty[0].longand 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
add a comment |
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.
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 theproperty[0].longand 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
add a comment |
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.
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.
answered Mar 7 at 22:09
OhgodwhyOhgodwhy
35.1k64069
35.1k64069
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 theproperty[0].longand 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
add a comment |
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 theproperty[0].longand 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
You can use
<v-autocomplete return-object ...and removeitem-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 seeitem.shorton the DOM unless I refresh. Should not that be gone since it is in thev-model?– DjSh
Mar 10 at 20:19
1
When you clear selection,
this.selectedwill benull, and yourv-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 yourpropertyarray, 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-ifworked. Do I still need the computed property?– DjSh
Mar 10 at 21:42