javascript - jQuery Tokeninput and the onFreeTaggingAdd callback -


the jquery plugin tokeninput (master branch) (https://github.com/loopj/jquery-tokeninput) has new feature adding tags. unfortunately feature far best documented @ twitter: https://twitter.com/loopj/status/332249287062851585.

i'm trying figure out how use onfreetaggingadd, unfortunately i'm jquery , javascript newbie.

in short callback take output api , use in tokenbox. way able modify tag (lower case etc) , add id. able replace id/tag if that's policy suggested api.

below, please see code far. i've tried several options set item=data , return value, far without success. appreciated!

onfreetaggingadd: function (item) {  $.post("../php/add_tagg_02.php", {tag: item, userid: "userid-dummy"} ) .done(function(data, status, xhr) { alert ("your suggested new tag " + data.name + " entered in database , considered future use."); console.log( data.name ); //returns "new" name api console.log( data.id ); //returns id provided api })     return item; //returns "old" name user input    }, 

i believe library sets freetag's id same name default, way change edit add_freetagging_tokens() method within library.

at point called, token nothing more string, change name, this:

onfreetaggingadd: function (item) {  $.post("../php/add_tagg_02.php", {tag: item, userid: "userid-dummy"} ) .done(function(data, status, xhr) { alert ("your suggested new tag " + data.name + " entered in database , considered future use."); console.log( data.name ); //returns "new" name api console.log( data.id ); //returns id provided api })     return data.name; //sets tokens name/id new name api. }, 

if did want customize id, should relatively simple change method return object, instead of string.

also aware token won't searchable for, unless update data source.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -