I'm using this plugin called TagHandler. Link: http://ioncache.github.io/Tag-Handler/ May I know how can I assign tags from the database and not hard code to jquery? Example, to assign tags is
$("#array_tag_handler").tagHandler({
assignedTags: [ 'C', 'Perl', 'PHP' ],
availableTags: [ 'C', 'C++', 'C#', 'Java', 'Perl', 'PHP', 'Python' ],
autocomplete: true
});
But I want it from mysql database.
They only gave example for available tags which is using the getData buildin function
$("#ajaxget_tag_handler").tagHandler({
getData: { id: 'user123', type: 'user' },
getURL: '/ajaxtest/get',
autocomplete: true
});
I need the php example. I don't know how to retrieve data in JSON format.
From the website..."By supplying a "getURL" for the tags to be retrieved via AJAX. When using this method, the server must supply a JSON formatted array named "availableTags" and optionally an additional array named "assignedTags"."
On the clientside you want to load the tag handler like so:
This calls the '/admin/tag/list' route and expects json back. On the server side you want to retrieve the list of tags and pass them back in json format.
Then build your array with the correct indices according to the Tag Handler documentation:
Note that if you want to preload some tags (eg tag1 and tag2) then just modify the array above so that it looks like this:
Then you need to json encode this array before returning it to the client: