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

Question about option "source" #21

Open
thomascenni opened this issue Nov 21, 2020 · 1 comment
Open

Question about option "source" #21

thomascenni opened this issue Nov 21, 2020 · 1 comment

Comments

@thomascenni
Copy link

Hi,
In case of Dynamic data source, using the code supplied in the documentation:

<script>
	document.addEventListener('DOMContentLoaded', function() {
		const tagsInput = document.getElementById('tags-with-source');
		new BulmaTagsInput(tagsInput, {
			source: async function(value) {
				// Value equal input value
				// We can then use it to request data from external API
				return await fetch("https://restcountries.eu/rest/v2/name/" + value)
					.then(function(response) {
						return response.json();
					});
		  	}
	  	});
	}, false);
</script>

it is not clear to me how data should be returned from the server.
I have a JSON object like this:

[{"name":"Allemand","text":"Allemand"},{"name":"Animateur D'Art","text":"Animateur D'Art"}]

returned from my server, and it's not rendered correctly (it appears in the list as undefined).
Thanks in advance, any help is really appreciated.

@illwrks
Copy link

illwrks commented Jul 28, 2023

For my future self...

[
    {
        "value":"1",
        "text":"Allemand"
    },
    {
        "value":"2",
        "text":"Animateur D'Art"
    }
]

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