Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to access the value of the v-model? #48

Closed
jonakirke94 opened this issue Nov 28, 2018 · 3 comments
Closed

Is it possible to access the value of the v-model? #48

jonakirke94 opened this issue Nov 28, 2018 · 3 comments
Assignees
Labels

Comments

@jonakirke94
Copy link

How can I get the value of the v-model so I can take actions depending on the value? It doesn't seem like you can access the v-model value

//TEMPLATE
<pre>{{id}}</pre> <!-- NO VALUE / NOT REACTIVE -->
<input type="text" v-model="id" name="id">	

//COMPONENT
import { createHelpers } from "vuex-map-fields";

const { mapFields } = createHelpers({
  getterType: "applicationModule/getField",
  mutationType: "applicationModule/updateField"
});

@Component({
	computed: {
		...mapFields({
                        `id:` 'newApplication.id',
			name: 'newApplication.name',
			description: 'newApplication.description',
		}),
	}
})
@jonakirke94
Copy link
Author

jonakirke94 commented Nov 28, 2018

It appears to work when mapping the object instead and accessing the properties on the object in the template:

<pre>{{app.id}}</pre> <!-- WORKS -->
<input type="text" v-model="app.id" name="id">

@Component({
	computed: {
		...mapFields({
			app: 'newApplication'
		}),
	}
})

Still baffled as to way the first example doesn't work. My state in my module is notated as this:
newApplication: {} as Application .. wondering if it has anything to do with that?

@maoberlehner
Copy link
Owner

Hey @jonakirke94!

There is a syntax error in the example you've posted: `id:` 'newApplication.id', (the backticks `) around id: please make sure that you don't have this error in your actual code.

If not, please provide a reduced test case on CodeSandbox (you can fork https://codesandbox.io/s/38y88yvoo1).

Thanks!

@maoberlehner
Copy link
Owner

Closing this because of inactivity. Feel free to open a new issue if this is still a problem. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants