Created
January 7, 2021 16:57
-
-
Save douglasmiranda/1c7ddb36eee035687f5f371c77b3ea28 to your computer and use it in GitHub Desktop.
Tagify: Format for server side comma separated / on form changes event / jQuery example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function ($) { | |
$input = $('#my-form') | |
.tagify() | |
.on('change', function (e, tagData) { | |
if (tagData === undefined) { | |
return; | |
} | |
// string [{"value":"test"}', '{"value":"test2"}] to JSON Object | |
var tags = JSON.parse(tagData); | |
// Converts into a simple array ["test", "test2"], then convert to string "test,test2" | |
var tags_parsed = tags.map(item => item.value).toString(); | |
// Then you can do some ajax post and send the tags_parsed to the server side. | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment