You can use the preprocessTag
function to check the given tag and eventually split it in some tags and add them to tag it using createTag
.
Code:
var $tagInp = $("#tagInp");
$tagInp.tagit({
allowSpaces: true,
preprocessTag: function (val) {
if (!val) {
return '';
}
var values = val.split(",");
if (values.length > 1) {
for (var i = 0; i < values.length; i++) {
$tagInp.tagit("createTag", values[i]);
}
return ''
} else {
return val
}
}
});
Demo: http://jsfiddle.net/IrvinDominin/GL6VK/
EDIT DELIMITER GOT FROM OPTION
You can get the delimiter using:
$tagInp.tagit('option','singleFieldDelimiter')
Code:
var $tagInp = $("#tagInp");
$tagInp.tagit({
allowSpaces: true,
preprocessTag: function (val) {
if (!val) {
return '';
}
var values = val.split($tagInp.tagit('option','singleFieldDelimiter'));
if (values.length > 1) {
for (var i = 0; i < values.length; i++) {
$tagInp.tagit("createTag", values[i]);
}
return ''
} else {
return val
}
}
});