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

How to get value of Select2? #14

Open
CFusionMM opened this issue Jul 10, 2022 · 2 comments
Open

How to get value of Select2? #14

CFusionMM opened this issue Jul 10, 2022 · 2 comments

Comments

@CFusionMM
Copy link

CFusionMM commented Jul 10, 2022

First of all thank you for these examples, they have helped me enormously with manupulating some fields on the admin side. Any chance you know how to get the value of a select2 field (im using the taxonomy ACF field). Basically want to change some checkbox group options based on what taxonomy they select. I was able to get most to work but for some reason cant figure out how to get the selected value of this field. See my code below, .Val() comes back null

var selManufacturer = acf.getField('field_629a3d70a424a'); var manufacturer = selManufacturer.val(); console.log(selManufacturer.data); console.log(manufacturer); if (!manufacturer) { // no state selected // don't need to do anything else console.log('no mid found, aborting'); return; }

@Hube2
Copy link
Owner

Hube2 commented Jul 11, 2022

That looks like the way I'd try to do it. It that's not it then I don't know. What is being logged to console?

@CFusionMM
Copy link
Author

selManufacturer returns an object but manufacturer returns null

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

No branches or pull requests

2 participants