I am trying to add some features to the jQuery tag-it plugin based on autocomplete:
a) I am trying to filter JSON data to display only the tag name.
JSON sample returned by /repo/json :
[{id:1, name:"0.8-alpha-1", category:"version"}, {id:2, name:"0.8-alpha-2", category:"version"}, {id:3, name:"0.8-alpha-3", category:"version"}, {id:4, name:"0.8-alpha-4", category:"version"}, {id:5, name:"0.8-alpha-1", category:"version"}, {id:6, name:"0.8-alpha-2", category:"version"}, {id:7, name:"0.8-alpha-3", category:"version"}, {id:8, name:"0.8-alpha-4", category:"version"}]
b) I want to send the tag identifier when the user sends the data, not the name.
c) I'm trying to add some kind of restriction to the input tag field: it cannot check a tag that is not in the JSON returned by my /repo/json call .
I donβt want to create a fork repository and possibly check for intersection between an array of users and a search using the beforeTagAdded option.
Currently, I am trying unsuccessfully because I donβt know where to find the list of tags to implement the intersection.
My js code is:
$(function(){ $("#singleFieldTags").tagit({ tagSource: function(search, showChoices) { $.ajax({ url: "/repo/json", dataType: "json", data: {q: search.term}, success: function(choices) { showChoices(choices); } })}, beforeTagAdded: function(event, ui) {
Html form:
<form name="data" action="/repo/uploadMole" method="POST" enctype="multipart/form-data"> <input name="tags" id="singleFieldTags" ><br/> <input type="Submit"> </form>